Replies: 1 comment
-
In the meantime, I've decided to split the testing so that JS files are run by jest and TS files run by ts-jest. This was the only way I could get things working. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm refactoring a JS project over to TS. During this process, I will need a test workflow that runs both JS and TS tests.
ts-jest
seems like a good candidate for this.While migrating tests over to ts-jest, I've noticed that some tests are now failing because
jest.mock
doesnt seem to be running(?), and as such, the code being tested is executing the dependency's actual code rather than it's mocked code.To demonstrated this, I've created an MRP here. To use this, delete/rename
jest.config.js
and runnpm test
to execute the test with plain node and it will pass, then restorejest.config.js
and runnpm test
again and the test will fail because the mock is no longer being called. We can also see that the actual code is being executed because of the log it writes.Anyone have any ideas what my
jest.mock
doesnt seem to be running, and how I can actually get this to work withts-jest
?Code being mocked:
Code being tested:
Test
Beta Was this translation helpful? Give feedback.
All reactions