Open bradley329 opened 1 month ago
I don't have an officially supported work around since I've dropped CJS support from the library. However, and I haven't tested this, I found jest-esm-transformer-2 which might help.
Another option might be to mock export-to-csv
's functions. If your tests have fixed input and output expectations, you can mock this library's functions to always return the expected "sane" output. The downside is that it might drift if things change in future versions. Granted, this library has pretty decent test coverage now, so it should be safe to trust its output will be consistent. Any expected breaking changes to output will be denoted by a major version bump, anyway.
Describe the bug possible related issue: https://github.com/alexcaza/export-to-csv/issues/87 I know that the new version of export-to-csv has some breaking change which exports ES modules instead of CommonJS now? But that caused our Jest to fail as it by default does not transform the ts files in export-to-csv. Is there a recommended approach to work this around? I saw this post: https://www.sobyte.net/post/2022-06/jest/ but looks like only option 2 is good for export-to-csv.🤔But it will lead to confusions.
To Reproduce Steps to reproduce the behavior: tsconfig.json: "compilerOptions": { "moduleResolution": "Node", "module": "CommonJS", } and package.json does NOT have "type": "module" as i am on commonjs.
Full error Jest encountered an unexpected token