2024-02-06 00:36:45 +01:00
|
|
|
import nextJest from 'next/jest.js'
|
2022-11-16 00:14:59 +01:00
|
|
|
|
|
|
|
const createJestConfig = nextJest({
|
|
|
|
dir: './'
|
|
|
|
})
|
|
|
|
|
2024-02-06 00:36:45 +01:00
|
|
|
/** @type {import('jest').Config} */
|
|
|
|
const customJestConfig = {
|
|
|
|
rootDir: '../',
|
2024-02-06 02:06:58 +01:00
|
|
|
setupFilesAfterEnv: ['<rootDir>/tests/jest.setup.ts'],
|
2022-11-16 00:14:59 +01:00
|
|
|
moduleDirectories: ['node_modules', '<rootDir>/src'],
|
|
|
|
testEnvironment: 'jsdom',
|
|
|
|
moduleNameMapper: {
|
2024-02-04 23:09:00 +01:00
|
|
|
'^@/(.*)$': '<rootDir>/$1',
|
2024-02-05 10:29:00 +01:00
|
|
|
'^@content/(.*)$': '<rootDir>/_content/$1',
|
|
|
|
'^@generated/(.*)$': '<rootDir>/generated/$1',
|
2022-11-16 00:14:59 +01:00
|
|
|
'^.+\\.(svg)$': '<rootDir>/tests/__mocks__/svgr-mock.tsx'
|
|
|
|
},
|
|
|
|
collectCoverage: true,
|
|
|
|
collectCoverageFrom: [
|
|
|
|
'src/**/*.{ts,tsx}',
|
|
|
|
'!src/**/*.{stories,test}.{ts,tsx}',
|
2024-02-04 12:51:49 +01:00
|
|
|
'!src/types/**/*.{ts,tsx}'
|
2022-11-16 00:14:59 +01:00
|
|
|
],
|
|
|
|
// note: this does not work with Next.js, hence workaround further down
|
|
|
|
// see: https://github.com/vercel/next.js/issues/35634#issuecomment-1115250297
|
|
|
|
// transformIgnorePatterns: ['node_modules/(?!(uuid|remark)/)'],
|
|
|
|
testPathIgnorePatterns: [
|
|
|
|
'node_modules',
|
|
|
|
'\\.cache',
|
|
|
|
'.next',
|
|
|
|
'coverage',
|
|
|
|
'\\.test.jsx'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
// https://github.com/vercel/next.js/issues/35634#issuecomment-1115250297
|
|
|
|
async function jestConfig() {
|
|
|
|
const nextJestConfig = await createJestConfig(customJestConfig)()
|
|
|
|
nextJestConfig.transformIgnorePatterns[0] = '/node_modules/(?!uuid|remark)/'
|
|
|
|
return nextJestConfig
|
|
|
|
}
|
|
|
|
|
|
|
|
export default jestConfig
|