-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjest.config.ts
59 lines (55 loc) · 1.87 KB
/
jest.config.ts
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
import type { Config } from 'jest'
import nextJest from 'next/jest'
import { pathsToModuleNameMapper } from 'ts-jest'
import { compilerOptions } from './tsconfig.json'
const createJestConfig = nextJest({
dir: './'
})
const customJestConfig: Config = {
verbose: true,
collectCoverage: true,
coverageReporters: process.env.CI ? ['lcov'] : ['json', 'lcov', 'html', 'text'],
setupFiles: ['jest-date-mock'],
setupFilesAfterEnv: ['<rootDir>/src/tests/jest/jest.setup.ts'],
preset: 'ts-jest',
roots: ['<rootDir>'],
moduleDirectories: ['node_modules', '<rootDir>/'],
modulePathIgnorePatterns: ['<rootDir>/.next', '<rootDir>/node_modules', '<rootDir>/public', '<rootDir>/dist/'],
collectCoverageFrom: [
'src/**/*.{js,jsx,ts,tsx}',
'!src/**/*.d.ts',
'!src/**/*.stories.{js,jsx,ts,tsx}',
'!src/**/*.test.{js,jsx,ts,tsx}',
'!src/**/index.{js,jsx,ts,tsx}',
'!src/types/**/*',
'!src/**/mock*.{js,jsx,ts,tsx}'
],
reporters: ['default', 'jest-sonar'],
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths),
'^antd/es/(.*)$': '<rootDir>/node_modules/antd/lib/$1',
'^@/(.*)$': '<rootDir>/src/$1'
},
snapshotResolver: '<rootDir>/src/tests/jest/jest.snapshot.js',
transformIgnorePatterns: ['/node_modules/', '^.+\\.module\\.(css|sass|scss)$'],
testEnvironment: 'jest-environment-jsdom',
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { presets: ['next/babel'] }]
},
coverageThreshold: {
global: {
branches: 80,
functions: 80,
lines: 80,
statements: 80
}
},
testEnvironmentOptions: {
customExportConditions: ['']
},
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/.next/'],
clearMocks: true
}
export default createJestConfig(customJestConfig)