-
Notifications
You must be signed in to change notification settings - Fork 266
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
I get Cannot find module 'csv-stringify/sync'
by running ts-jest
#309
Comments
UPDATE: I noticed that the test will pass with I know that csv module's export was changed from |
This is probably related to jestjs/jest#9771. i.e. Jest is not using package.json's exports field. In that case you'd have to use Edit: Maybe there's a chance you could use |
Thanks for advice! |
Thanks @dantman for the advice. I was able to get my test working by adding a
|
@scottgeye thank you so much for posting that. Works for csv-parse, too! |
I am also having this issue with v6.0.5 |
@scottgeye Thank you for posting the solution! I had the same issue on Here is my project folder structure:
I wanted to test module1 which has Here are the jest config files look like in my project:
The jest config file is read at the folder level when the jest command is ran unless the config file path is specified. |
+1. Though moduleNameMapper sol'n fixed it. |
Add csv-parse/sync to module mapper Ref: adaltas/node-csv#309 (comment) Signed-off-by: shahulsonhal <shahulsonhal@gmail.com>
Add csv-parse/sync to module mapper Ref: adaltas/node-csv#309 (comment) Signed-off-by: shahulsonhal <shahulsonhal@gmail.com>
Doing some cleanup, closing. |
I met the same issue when using Node: 16.19.1 "moduleNameMapper": {
"axios": "axios/dist/node/axios.cjs",
"csv-stringify/browser/esm": "csv-stringify/dist/cjs/index.cjs"
} |
Describe the bug
As the title says, I can't use
csv-stringify/sync
in my tests by running ts-jest. But I can build and run by ts-node.Dependencies:
Environment:
To Reproduce
I have prepared a repository for the explanation. If you want to see the whole thing(Jest configuration or tsconfig or like that), please check there:
https://github.com/OldBigBuddha/cant-find-csv-stringify-in-jest-test
Main code:
Test Code:
These codes can be transpiled to JavaScript by
tsc
. But If you run it byts-jest
, it will fail because ofCannot find module 'csv-stringify/sync' from 'src/main.ts'
Additional context
Nothing.
The text was updated successfully, but these errors were encountered: