full upgrade to dev
This commit is contained in:
@@ -1,44 +1,38 @@
|
||||
import type { Config } from 'jest'
|
||||
import nextJest from 'next/jest.js'
|
||||
|
||||
import type { Config } from "jest";
|
||||
import nextJest from "next/jest.js";
|
||||
|
||||
const createJestConfig = nextJest({
|
||||
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
|
||||
dir: './',
|
||||
})
|
||||
|
||||
dir: "./",
|
||||
});
|
||||
|
||||
// Add any custom config to be passed to Jest
|
||||
const config: Config = {
|
||||
coverageProvider: 'babel',
|
||||
testEnvironment: 'jsdom',
|
||||
coverageProvider: "v8",
|
||||
testEnvironment: "jsdom",
|
||||
// Add more setup options before each test is run
|
||||
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
|
||||
setupFilesAfterEnv: ["<rootDir>/jest.setup.ts"],
|
||||
// Ignore tests inside __mocks__ directory
|
||||
testPathIgnorePatterns: ['/node_modules/', '/__mocks__/'],
|
||||
testPathIgnorePatterns: ["/node_modules/", "/__mocks__/", "/.next/"],
|
||||
// Transform react-markdown and other ESM modules
|
||||
transformIgnorePatterns: [
|
||||
'node_modules/(?!(react-markdown|remark-.*|rehype-.*|unified|bail|is-plain-obj|trough|vfile|vfile-message|unist-.*|micromark|parse-entities|character-entities|mdast-.*|hast-.*|property-information|space-separated-tokens|comma-separated-tokens|web-namespaces|zwitch|longest-streak|ccount)/)'
|
||||
"node_modules/(?!(react-markdown|remark-.*|rehype-.*|unified|bail|is-plain-obj|trough|vfile|vfile-message|unist-.*|micromark|parse-entities|character-entities|mdast-.*|hast-.*|property-information|space-separated-tokens|comma-separated-tokens|web-namespaces|zwitch|longest-streak|ccount)/)",
|
||||
],
|
||||
// Fix for production React builds
|
||||
testEnvironmentOptions: {
|
||||
customExportConditions: [''],
|
||||
},
|
||||
// Module name mapping to fix haste collision
|
||||
moduleNameMapper: {
|
||||
'^@/(.*)$': '<rootDir>/$1',
|
||||
},
|
||||
// Fix haste collision by excluding .next directory
|
||||
haste: {
|
||||
hasteImplModulePath: undefined,
|
||||
"^@/(.*)$": "<rootDir>/$1",
|
||||
},
|
||||
// Exclude problematic directories from haste
|
||||
modulePathIgnorePatterns: ['<rootDir>/.next/'],
|
||||
modulePathIgnorePatterns: ["<rootDir>/.next/", "<rootDir>/node_modules/"],
|
||||
// Clear mocks between tests
|
||||
clearMocks: true,
|
||||
// Reset modules between tests
|
||||
resetMocks: true,
|
||||
// Restore mocks between tests
|
||||
restoreMocks: true,
|
||||
}
|
||||
|
||||
// Max workers for better performance
|
||||
maxWorkers: "50%",
|
||||
};
|
||||
|
||||
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
|
||||
export default createJestConfig(config)
|
||||
export default createJestConfig(config);
|
||||
|
||||
Reference in New Issue
Block a user