-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
moduleNameMapper with next/jest no longer works well with absolute imports #36682
Comments
This also seems to break the
|
Solution: const nextJest = require('next/jest');
const customJestConfig = {/* With custom configuration */};
const createJestConfig = nextJest({
dir: './',
})(customJestConfig);
module.exports = async () => {
// Create Next.js jest configuration presets
const jestConfig = await createJestConfig();
// Custom `moduleNameMapper` configuration
const moduleNameMapper = {
...jestConfig.moduleNameMapper,
'^@/(.*)$': '<rootDir>/src/$1',
};
return { ...jestConfig, moduleNameMapper };
}; See |
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 have absolute imports configured in tsconfig, as well as in my
jest
config:with this config, importing a
.module.css
file in a component via absolute import was handled correctly before[email protected]
:since
next/[email protected]
however (specifically with #36312) this changed because now user-providedmoduleNameMapper
will match before anything auto-configured bynext/jest
, which means i would have to manually copy the mapping for.css
,.module.css
, images etc.Expected Behavior
see above
To Reproduce
see above
The text was updated successfully, but these errors were encountered: