-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.js
More file actions
57 lines (53 loc) · 1.75 KB
/
jest.config.js
File metadata and controls
57 lines (53 loc) · 1.75 KB
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
const nextJest = require('next/jest')
const { pathsToModuleNameMapper } = require('ts-jest')
const { compilerOptions } = require('./tsconfig')
const ignores = [
'/node_modules/',
'/__fixtures__/',
'/fixtures/',
'/__tests__/helpers/',
'/__tests__/utils/',
'__mocks__',
'__stubs__',
]
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 = {
testMatch: ['<rootDir>/src/**/__tests__/*.spec.(js|ts|tsx)'],
testEnvironment: 'jest-environment-jsdom',
moduleFileExtensions: ['js', 'ts', 'tsx'],
moduleDirectories: ['node_modules', '<rootDir>/'],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
}),
'\\.(css|scss)$': 'identity-obj-proxy',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|pdf|svg)$':
'<rootDir>/jest/moduleMapper/fileMock.ts',
},
testPathIgnorePatterns: [...ignores],
collectCoverageFrom: ['src/**/*.+(js|jsx|ts|tsx)'],
coveragePathIgnorePatterns: [
...ignores,
'jest/',
'<rootDir>/src/pages/',
'src/(umd|cjs|esm)-entry.js$',
],
coverageDirectory: 'coverage',
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
setupFiles: ['<rootDir>/jest/patch-cssom.js'],
setupFilesAfterEnv: ['<rootDir>/jest/setupAfterEnv.ts'],
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)