-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjest.config.js
57 lines (54 loc) · 1.97 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
/** @format */
/* eslint @typescript-eslint/no-var-requires:0 */
const path = require('path');
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { jsWithTs: tsjPreset } = require('ts-jest/presets');
// In the following statement, replace `./tsconfig` with the path to your `tsconfig` file
// which contains the path mapping (ie the `compilerOptions.paths` option):
const { compilerOptions } = require('./tsconfig');
const localPathMapper = {
...pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
'^@public/(.*?)(\\?.*)?$': '<rootDir>/public/$1',
'^@images/(.*?)(\\?.*)?$': '<rootDir>/public/images/$1',
// eslint-disable-next-line max-len
'\\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|css|scss|sass|less)(\\?.*)?$':
'<rootDir>/apps/portal/__mocks__/fileMock.js',
};
if (localPathMapper['^@public/(.*)$']) {
delete localPathMapper['^@public/(.*)$'];
}
if (localPathMapper['^@images/(.*)$']) {
delete localPathMapper['^@images/(.*)$'];
}
module.exports = {
testTimeout: 180000,
verbose: true,
preset: 'ts-jest',
testEnvironment: './vscode-environment.js',
setupFiles: ['./jest.setup.ts'],
snapshotSerializers: ['enzyme-to-json/serializer'],
globals: {
'ts-jest': {
tsconfig: 'tsconfig.jest.json',
// Disable type-checking
isolatedModules: true,
},
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
moduleNameMapper: localPathMapper,
transform: {
...tsjPreset.transform,
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)(\\?.*)?$': 'jest-transform-stub',
'^.+\\.svg$': 'jest-svg-transformer',
},
// transformIgnorePatterns: ['node_modules/(?!(simple-git/src))/'],
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/(*.)+(spec|test).[jt]s?(x)'],
testPathIgnorePatterns: [
'<rootDir>/.git/',
'<rootDir>/dist/',
'<rootDir>/.next/',
'<rootDir>/apps/portal/.next/',
'<rootDir>/node_modules/',
'<rootDir>/.local/',
],
};