-
Notifications
You must be signed in to change notification settings - Fork 454
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
Issue with rewire "Cannot find module" #1029
Comments
Same here |
+1 |
Any ideas about workaround here? Seems rewire just |
+1 |
2 similar comments
+1 |
+1 |
I think this might be related to |
bump |
Well, if you use typescript, you do not want to rely to babel. |
+1 |
1 similar comment
+1 |
I had the same issue on using SolutionUse Example: Install
Rewrite "scripts": {
...
- "test": "jest",
+ "test": "ts-node -O '{\"module\":\"commonjs\"}' node_modules/jest/bin/jest.js",
...
}, Run test as usual.
And everything goes well! Explanation
|
Hi guys, I will close this as In general, Also if you have any ideas to fix this issue for |
Just want to leave a comment here in case anybody else using WebStorm with a Jest run configuration happens to be looking for a fix. I can confirm that @grainrigi's solution of adding Fortunately, you can simply add I suspect this would also work for IntelliJ, but haven't tested it personally. |
@grainrigi and @TheJizel both of you are life-saver. |
I am getting “cannot find module” even for a js file. Please help!! |
A small add on for those who is searching it like me. If you want to rewire a private method of a export class, here is the trick: https://stackoverflow.com/a/67741151/2450847. |
Just in case anyone also has this problem: I kept getting an error
This was not my idea. See here: https://github.com/TypeStrong/ts-node/issues/313#issuecomment-741249846 |
Issue
I'm unable to use rewire with ts-jest, it seems to works with
.js
files, but it does not with.ts
files as supposed to.Expected behavior
Being able to rewire a module with jest with ts-jest.
Debug log:
content of ts-jest.log
Minimal repo
https://github.com/DavidBabel/test-jest-rewire-typescript
The text was updated successfully, but these errors were encountered: