Closed msafi closed 2 years ago
Same with using @monaco-editor/react
, the import
syntax in monaco-editor
breaks jest.
For now I went with
- module.exports = createJestConfig(customJestConfig);
+ module.exports = async () => ({
+ ...await createJestConfig(customJestConfig)(),
+ transformIgnorePatterns: [
+ 'node_modules/(?!(monaco-editor)/)',
+ '^.+\\.module\\.(css|sass|scss)$',
+ ]
});
Should work for @msafi as workaround for now, just replace monaco-editor
with remark
. More libs can be added alongside, |
-separated (i.e. 'node_modules/(?!(lib1|lib2|lib3)/)'
transformIgnorePatterns
must be added outside of createJestConfig
as the latter overrides the provided transformIgnorePatterns
in case of node_modules
node_modules
are not transpiled currently. This is a duplicate of #35634.
module.exports = async () => ({ + ...await createJestConfig(customJestConfig)(), + transformIgnorePatterns: [ + 'node_modules/(?!(monaco-editor)/)', + '^.+\\.module\\.(css|sass|scss)$', + ] });
THIS helped me so much I thought I am going insane! thanks for finding the bug and temp solution
@pantchox @burtek I resorted to mocking the offending modules.
The solution that @burtek didn't work for me. I started getting errors about transforming JSX and TypeScript when I tried to implement @burtek's solution.
@msafi Had the same happen to me when I forgot the ()
at the end of await createJestConfig(customJestConfig)()
- maybe that's the issue?
Also, only transformIgnorePatterns
needs to be outside createJestConfig
, the rest can go in customJestConfig
- it should work fine.
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Verify canary release
Provide environment information
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
I'm using the module
remark
in one of my components that I need to test. But when I run the test for that component with Jest. I see the following errorMy
jest.config.js
is the followingExpected Behavior
I expect
next/jest
to handle this situation?To Reproduce
Follow the recommended steps to setup a Next.js project with Jest support, then build a component that uses the
remark
module and write a test for it.