-
Notifications
You must be signed in to change notification settings - Fork 10
/
jest.config.js
64 lines (59 loc) · 1.65 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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 = {
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
moduleNameMapper: {
'^components/(.*)$': '<rootDir>/src/components/$1',
'^utils/(.*)$': '<rootDir>/src/utils/$1',
'^constants/(.*)$': '<rootDir>/src/constants/$1',
'^pages/(.*)$': '<rootDir>/src/pages/$1',
'^context/(.*)$': '<rootDir>/src/context/$1',
'^libs/(.*)$': '<rootDir>/src/libs/$1',
},
testEnvironment: 'jest-environment-jsdom',
testPathIgnorePatterns: [
'<rootDir>/.next/',
'<rootDir>/src/types/',
'<rootDir>/node_modules/',
'<rootDir>/scripts/',
'<rootDir>/cypress/',
],
transformIgnorePatterns: [
'/node_modules/',
'^.+\\.module\\.(css|sass|scss)$',
],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
collectCoverage: false,
globals: {
'ts-jest': {
tsConfig: 'tsconfig.jest.json',
babelConfig: true,
diagnostics: false,
},
},
preset: 'ts-jest',
collectCoverageFrom: [
'**/*.(ts|tsx)',
'!**/*.d.ts',
'!**/*.stories.js',
'!**/*.stories.tsx',
'!**/__stubs__/**',
],
coverageProvider: 'v8',
}
const jestConfig = async () => {
const nextJestConfig = await createJestConfig(customJestConfig)()
return {
...nextJestConfig,
moduleNameMapper: {
'\\.svg': '<rootDir>/__mocks__/svgrMock.js',
// Workaround to put our SVG mock first
...nextJestConfig.moduleNameMapper,
},
}
}
module.exports = jestConfig