-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.ts
More file actions
executable file
·41 lines (37 loc) · 1010 Bytes
/
jest.config.ts
File metadata and controls
executable file
·41 lines (37 loc) · 1010 Bytes
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 type { Config } from 'jest';
import { pathsToModuleNameMapper, createDefaultEsmPreset } from 'ts-jest';
import dotenv from 'dotenv';
import fs from 'node:fs';
import path from 'node:path';
dotenv.config();
const basePreset = createDefaultEsmPreset({
tsconfig: 'tsconfig.json'
});
const compilerOptions = JSON.parse(
fs.readFileSync(path.join(process.cwd(), 'tsconfig.json'), 'utf-8')
).compilerOptions;
const moduleNameMapper = {
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
useESM: true
}),
'^(\\.{1,2}/.*)\\.js$': '$1',
}
};
export default {
projects: [
{
displayName: 'node',
...basePreset,
transform: {
'^.+\\.tsx?$': ['ts-jest', { useESM: true }]
},
extensionsToTreatAsEsm: ['.ts'],
...moduleNameMapper,
testEnvironment: 'node',
testMatch: ['<rootDir>/src/**/*.test.ts'],
modulePathIgnorePatterns: ['<rootDir>/dist/']
}
]
} satisfies Config;