-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
37 lines (37 loc) · 1.66 KB
/
jest.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module.exports = {
roots: ['./src'],
preset: 'ts-jest',
testEnvironment: 'node',
globals: {
// XXX we must specify a custom tsconfig for tests because we need the typescript transform
// to transform jsx into js rather than leaving it jsx such as the next build requires. you
// can see this setting in tsconfig.jest.json -> "jsx": "react"
// See https://github.com/vercel/next.js/issues/8663
'ts-jest': {
tsconfig: 'tsconfig.json'
}
},
/**
* Map our module path aliases, so that Jest can understand modules loaded using "@modules" and load the proper file.
* Required, or Jest will fail to import dependencies from tests.
*
* XXX The below list must match `tsconfig.json:compilerOptions.paths`, so the Next.js app and Jest resolve all aliases the same way.
*
* @see https://nextjs.org/docs/advanced-features/module-path-aliases
* @see https://github.com/ilearnio/module-alias/issues/46#issuecomment-546154015
*/
moduleNameMapper: {
'^@styles/(.*)$': '<rootDir>/src/styles/$1',
'^@hooks/(.*)$': '<rootDir>/src/hooks/$1',
'^@utils/(.*)$': '<rootDir>/src/utils/$1',
'^@icons/(.*)$': '<rootDir>/src/icons/$1'
},
modulePathIgnorePatterns: ['.next/'],
runner: 'groups', // Allow to use jest-runner-groups - See https://github.com/eugene-manuilov/jest-runner-groups#update-jest-config
setupFilesAfterEnv: [
'jest-extended', // Extends native "expect" abilities - See https://github.com/jest-community/jest-extended
'jest-expect-message', // Allows to add additional message when test fails - See https://github.com/mattphillips/jest-expect-message
'./jest.setup.js',
'./jest.extends.ts'
]
};