-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 1.0.0 breaks Typescript/Mocha Workflow #101
Comments
Hey @hzzzln, As for the error - I think the Mocha and Jest generally can't coexist. The same error you get doing: yarn init -y
yarn add -D typescript @types/jest @types/mocha
echo "" >> index.ts
node_modules/typescript/bin/tsc index.ts The newly added Jest matchers are helpers if you use Jest for unit testing. Otherwise, they should not impact your workflow with other testing libraries. You don't have to install Matchers are for Jest only, with other assertion libraries you don't get them. Please let me know if that clarifies things. |
I also use TypeScript and mocha for testing and got similar issues. We don't have
This is with this reproduction:
|
Thanks for your reply @m-radzikowski ! Unfortunately, I'm running into the same errors as @rbargholz . Installing jest in the first place was motivated by these compile errors. |
@hzzzln, @rbargholz - please check out the 2.0.0-beta.1 release - it includes |
@m-radzikowski Thank you, I will take a look at that. |
Thanks again for pushing a new version so quickly. Now Jest indeed gets installed as a dependency, but I'm just back to the original errors about subsequent variable declarations. Is there maybe a way to make the Jest feature in aws-sdk-client-mock entirely optional? I.E., I don't want Jest, because it conflicts with Mocha, but I need Jest because aws-sdk-client-mock depends on it. |
Right 🤦♂️ A workaround would be to not have the Jest types as a dependency in the lib (like in v2.0.0-beta.0) and to enable TS skipLibCheck option in your As for making this optional dependency - I don't think the Node ecosystem supports something like that. The only solution that will prevent errors for all users would be to extract the helper Jest matchers as a separate dependency that you can install next to the |
Splitting it up into multiple packages was also my first idea, but I imagined it would be a radical step and quite a bit of work. I was wondering if there was some kind of conditional import:
But after some superficial googling this is either not possible or at least not cleanly possible. Please contact me if you need anything else in regards to this issue, and thank you for your time so far. |
I'm not an npm expert, but is another option here something that can be done with peer dependencies? |
Peer dependencies won't help. From NPM v7 they are installed by default, so you will get the |
Just released: Jest matchers were removed from the main library. They are now available as a separate dependency ( Please use this beta version, if no one will report further problems I will release |
Thanks for the fix. I can confirm that |
Checklist
Bug description
We use this library in our tests using Typescript and Mocha as a test runner. We recently wanted to update to version 1.0.0, however, the newly added Jest dependency breaks compatibility with Mocha.
Reproduction
Doing
will result in a lot of errors of the form
Environment
The text was updated successfully, but these errors were encountered: