-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
jest.config.ts
57 lines (51 loc) · 1.33 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
import nextJest from 'next/jest';
import type { Config } from '@jest/types';
const createConfig = nextJest({
dir: './'
});
const customConfig: Config.InitialOptions = {
verbose: true,
preset: 'ts-jest',
testEnvironment: 'jest-environment-jsdom',
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleDirectories: ['<rootDir>/node_modules', '<rootDir>/src'],
testPathIgnorePatterns: [
'<rootDir>/.next',
'<rootDir>/.husky',
'<rootDir>/.vscode',
'<rootDir>/.github',
'<rootDir>/node_modules',
'<rootDir>/coverage',
'<rootDir>/dist'
],
transform: {
'^.+\\.ts?$': 'ts-jest'
},
globals: {
'ts-jest': {
tsconfig: {
jsx: 'react-jsx'
}
}
},
moduleNameMapper: {
/**
* Handle CSS imports (with CSS modules)
* @see https://jestjs.io/docs/webpack#mocking-css-modules
*/
'\\.(scss|sass|css)$': 'identity-obj-proxy',
/**
* Handle image imports
* @see https://jestjs.io/docs/webpack#handling-static-assets
*/
'^.+\\.(jpg|jpeg|png|gif|webp|avif|svg)$':
'<rootDir>/__mocks__/fileMock.js',
/**
* Handle alias import and module path alias
*/
'^@/(.*)$': '<rootDir>/src/$1'
},
coverageDirectory: '<rootDir>/coverage',
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}']
};
module.exports = createConfig(customConfig);