-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjest.config.ts
41 lines (37 loc) · 1.22 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
import dotenv from 'dotenv';
import { getTsconfig } from 'get-tsconfig';
import { Config } from 'jest';
import path from 'path';
import { pathsToModuleNameMapper } from 'ts-jest';
const fullTsconfig = getTsconfig();
if (!fullTsconfig) {
throw new Error(`a "tsconfig.json" must be provided`);
}
// Load test variables if any
dotenv.config({ path: path.resolve(__dirname, './.env.jest') });
dotenv.config({ path: path.resolve(__dirname, './.env.jest.local') });
// Add any custom config to be passed to Jest
const customJestConfig: Config = {
preset: 'ts-jest',
setupFilesAfterEnv: [],
moduleDirectories: ['node_modules', '<rootDir>/'],
moduleNameMapper: {
...(fullTsconfig.config.compilerOptions && fullTsconfig.config.compilerOptions.paths
? pathsToModuleNameMapper(fullTsconfig.config.compilerOptions.paths, { prefix: '<rootDir>/' })
: {}),
},
testEnvironment: 'jest-environment-node',
modulePathIgnorePatterns: ['<rootDir>/data/'],
testPathIgnorePatterns: ['<rootDir>/data/', '<rootDir>/node_modules/'],
transformIgnorePatterns: [],
extensionsToTreatAsEsm: ['.ts'],
transform: {
'\\.[jt]s$': [
'ts-jest',
{
useESM: true,
},
],
},
};
export default customJestConfig;