Replies: 1 comment 3 replies
-
Hi, I'm not sure we should completely throw away the default const nextJest = require('next/jest')
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})
// Add any custom config to be passed to Jest
const customJestConfig = {
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ['node_modules', '<rootDir>/'],
testEnvironment: 'jest-environment-jsdom',
}
module.exports = async (...args) => {
const fn = createJestConfig(customJestConfig)
const res = await fn(...args)
res.transformIgnorePatterns = res.transformIgnorePatterns.map(pattern => {
if (pattern === '/node_modules/') {
return '/node_modules(?!/excluded-module)/'
}
return pattern
})
return res
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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
Some libraries ship
es6
code and require to usenext-transpile-modules
.It could be easy to transpile these by specifiying in
transformIgnorePatterns
, but the default config is not allowing overrides.next.js/packages/next/build/jest/jest.ts
Line 118 in cc5345b
Expected Behavior
Fully replace
transformIgnorePatterns
if it's specified inresolvedJestConfig
.To Reproduce
N/A
Beta Was this translation helpful? Give feedback.
All reactions