-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.js
47 lines (37 loc) · 1.41 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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { pathsToModuleNameMapper } = require('ts-jest');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { compilerOptions } = require('./tsconfig.json');
module.exports = {
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['/node_modules/', '/.next/'],
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.tsx',
'src/**/*.ts',
'src/core/**/*.ts',
'!src/styles/**.{ts,tsx}',
'!src/core/infra/**/*.ts',
'!src/**/*.{spec,test}.tsx',
'!src/pages/_app.tsx',
'!src/pages/_document.tsx',
],
setupFilesAfterEnv: ['<rootDir>/.jest/setup.ts'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { presets: ['next/babel'] }],
},
transformIgnorePatterns: ['/node_modules/(?!swiper|ssr-window|dom7)'],
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: {
// Handle CSS imports (with CSS modules)
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
// Handle CSS imports (without CSS modules)
'^.+\\.(css|sass|scss)$': '<rootDir>/__mocks__/style-mock.js',
// Handle image imports
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': `<rootDir>/__mocks__/file-mock.js`,
'swiper\\/css': '<rootDir>/__mocks__/style-mock.js',
...pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>',
}),
},
};