-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathjest.config.ts
42 lines (40 loc) · 1.38 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
import { readFileSync } from 'fs';
import { resolve } from 'path';
import type { Config } from 'jest';
import JSON5 from 'json5';
import { pathsToModuleNameMapper } from 'ts-jest';
const isCI = !!process.env['CI'];
const rootDir = __dirname;
const tsconfigPath = resolve(rootDir, 'tsconfig.json');
const tsconfigContents = readFileSync(tsconfigPath, 'utf8');
const tsconfig = JSON5.parse(tsconfigContents);
const ESM_PACKAGES = ['graphql-federation-gateway-audit'];
export default {
testEnvironment: 'node',
rootDir,
restoreMocks: true,
reporters: ['default'],
modulePathIgnorePatterns: ['dist'],
collectCoverage: false,
cacheDirectory: resolve(rootDir, `${isCI ? '' : 'node_modules/'}.cache/jest`),
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.m?(t|j)s?$': 'babel-jest',
},
moduleNameMapper: {
'^graphql$': '<rootDir>/node_modules/graphql/index.js',
vitest: '<rootDir>/vitest-jest.js',
...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, {
prefix: `${rootDir}/`,
useESM: true,
}),
},
transformIgnorePatterns: [`node_modules/(?!(${ESM_PACKAGES.join('|')})/)`],
testPathIgnorePatterns: [
'/node_modules/',
// we dont care about leaks in internal tests
// furthermore, some internal files use ESM (and import.meta) which jest does not support
'internal/',
],
testMatch: ['**/*.(test|spec).ts'],
} satisfies Config;