forked from leather-io/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
executable file
·49 lines (45 loc) · 1.46 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
const { version } = require('./package.json');
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { compilerOptions } = require('./tsconfig');
const pathNames = {};
Object.keys(compilerOptions.paths).forEach(key => {
const [path] = compilerOptions.paths[key];
if (key.includes('/ui')) {
return;
}
if (path.startsWith('../')) {
pathNames[key.replace(/\*/g, '(.*)')] = `<rootDir>/${path.slice(3).replace(/\*/g, '$1')}`;
return;
} else {
pathNames[key.replace(/\*/g, '(.*)')] = `<rootDir>/src/${path.replace(/\*/g, '$1')}`;
}
});
module.exports = {
setupFilesAfterEnv: ['./tests/jest-unit.setup.js'],
collectCoverage: true,
coverageReporters: ['html', 'json-summary'],
collectCoverageFrom: ['src/**/*.{ts,tsx}'],
testEnvironment: 'node',
globals: {
'ts-jest': {
// https://huafu.github.io/ts-jest/user/config/diagnostics
diagnostics: false,
tsconfig: '<rootDir>/tests/tsconfig.json',
},
VERSION: version,
},
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node', 'd.ts'],
moduleNameMapper: {
...pathNames,
...pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
},
roots: ['<rootDir>/tests', '<rootDir>/src'],
preset: 'ts-jest',
testMatch: ['**/?(*.)+(spec).(js|ts|tsx)'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.tsx?$': 'babel-jest',
'^.+\\.(j|t)sx?$': '@swc-node/jest',
},
cacheDirectory: '<rootDir>/.jest-cache',
};