forked from leather-io/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.integration.config.js
52 lines (47 loc) · 1.57 KB
/
jest.integration.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
const { version } = require('./package.json');
const { pathsToModuleNameMapper } = require('ts-jest');
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-legacy/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-legacy/tsconfig.json',
},
VERSION: version,
},
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node', 'd.ts'],
moduleNameMapper: {
...pathNames,
...pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
},
roots: ['<rootDir>/tests-legacy', '<rootDir>/src'],
preset: 'ts-jest',
testMatch: ['**/?(*.)+(spec).(js|ts|tsx)'],
testRunner: 'jest-circus/runner',
cacheDirectory: '<rootDir>/.jest-cache',
transform: {
'^.+\\.tsx?$': '@swc-node/jest',
},
testTimeout: 60000,
globalSetup: '<rootDir>/tests-legacy/global-setup.ts',
globalTeardown: '<rootDir>/tests-legacy/global-teardown.ts',
};