-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Mocking with jest doesn't work #713
Comments
similar issues with Sinon stub/spy: |
Please, check the latest version |
no change for Sinon |
@rosmcmahon I wrote up a small answer on SO on how you can generally use Sinon alongside Quibble (or any other similar tool, like Proxyquire) to mock modules when running SWC. Assumes your target module type is "commonjs". |
yeah, catching up on this again. basically sinon recognising that swc is building the module exports in a more correct way, but that it's out of scope for their project to support this. |
The problem is that Jest is a combination of many things:
By itself, nether Jest nor Sinon can know that an object is a module with exports and what you want to do with it 🤷 Both require the user to know what they are looking at. |
thanks @fatso83, sorry for the delay. |
In the article I have out for review I discuss three different approaches to exactly this issue, one of which is the tool independent route of exposing ways of injecting dependencies. I guess you are doing something similar to what I propose there? Would really like some extra set of eyes on this, so if you could spare five minutes I can perhaps help quite a few people in avoiding the trouble you experienced 🙏 |
Hi, this is
jest.config.template.js
:this is the test file:
result an error of
TypeError: _getBankTransaction.getBankTransactionOrFail.mockResolvedValueOnce is not a function
.using ts-jest preset works as expected
versions:
"@swc-node/jest": "1.6.5",
"jest": "28.1.3"
The text was updated successfully, but these errors were encountered: