-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.ts
55 lines (50 loc) · 1.68 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import type { Config } from '@jest/types';
// Sync object
const config: Config.InitialOptions = {
preset: 'ts-jest/presets/default-esm', // Use the ESM preset of ts-jest
collectCoverage: true,
coverageDirectory: 'coverage',
collectCoverageFrom: [
'src/**/*.ts',
'src/**/*.mts',
'!src/**/*.d.ts',
'!src/**/*.d.mts',
],
// moduleNameMapper: {
// '^(\\.{1,2}/.*)\\.js$': '$1', // Redirect .js imports to their .ts files in tests
// },
extensionsToTreatAsEsm: ['.ts'], // Treat .ts files as ESM
testEnvironment: 'jsdom', // Set the test environment to node
transform: {
'^.+\\.m?[tj]s?$': ['ts-jest', { useESM: true }],
},
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(m)?ts$',
moduleFileExtensions: ['ts', 'js', 'json', 'node'], // File extensions that Jest will scan
resolver: 'ts-jest-resolver', // Use the ts-jest resolver to handle module resolution
bail: false, // Do not bail on the first test failure
};
export default config;
// export default {
// testEnvironment: 'jsdom',
// preset: 'ts-jest/presets/default-esm',
// // transform: {
// // '^.+\\.m?[tj]s?$': ['ts-jest', { useESM: true }],
// // },
// // testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(m)?ts$',
// // moduleNameMapper: {
// // '^(\\.{1,2}/.*)\\.(m)?js$': '$1',
// // },
// // testPathIgnorePatterns: [
// // "/node_modules/",
// // "/dist/", // Ignore the dist directory
// // "/.rollup.cache/" // Ignore the .rollup.cache directory
// // ],
// coverageDirectory: 'coverage',
// collectCoverageFrom: [
// 'src/**/*.ts',
// 'src/**/*.mts',
// '!src/**/*.d.ts',
// '!src/**/*.d.mts',
// ],
// bail: false,
// }