-
Notifications
You must be signed in to change notification settings - Fork 331
/
jest.config.js
74 lines (66 loc) · 2.45 KB
/
jest.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const { resolve } = require('path');
const { pathsToModuleNameMapper } = require('ts-jest');
const JSON5 = require('json5');
const CI = !!process.env.CI;
const { readFileSync } = require('fs');
const ROOT_DIR = __dirname;
const TSCONFIG = resolve(ROOT_DIR, 'tsconfig.json');
const tsconfigStr = readFileSync(TSCONFIG, 'utf8');
const tsconfig = JSON5.parse(tsconfigStr);
process.env.LC_ALL = 'en_US';
let testMatch = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
if (process.env.LEAK_TEST) {
testMatch.push('!**/examples/grpc-*/**');
testMatch.push('!**/examples/sqlite-*/**');
testMatch.push('!**/examples/mysql-*/**');
testMatch.push('!**/examples/v1-next/grpc-*/**');
testMatch.push('!**/examples/v1-next/sqlite-*/**');
testMatch.push('!**/examples/v1-next/mysql-*/**');
testMatch.push('!**/examples/federation-example/tests/polling.test.ts');
}
testMatch.push(process.env.INTEGRATION_TEST ? '!**/packages/**' : '!**/examples/**');
testMatch.push(
process.env.INTEGRATION_TEST
? '**/packages/**/__integration_tests__/**'
: '!**/packages/**/__integration_tests__/**',
);
testMatch.push(
process.env.INTEGRATION_TEST && !process.env.LEAK_TEST
? '**/packages/plugins/newrelic/tests/**'
: '!**/packages/plugins/newrelic/tests/**',
);
if (process.env.E2E_TEST) {
testMatch = ['**/e2e/**/?(*.)+(spec|test).[jt]s?(x)'];
} else {
testMatch.push('!**/e2e/**/?(*.)+(spec|test).[jt]s?(x)');
}
/** @type {import('jest').Config} */
module.exports = {
...(process.env.E2E_SERVE_RUNNER === 'docker'
? {
maxWorkers: 5, // TODO: running with more than 5 workers breaks docker
}
: {}),
prettierPath: null, // not supported before Jest v30 https://github.com/jestjs/jest/issues/14305
testEnvironment: 'node',
rootDir: ROOT_DIR,
restoreMocks: true,
reporters: ['default'],
modulePathIgnorePatterns: ['dist', 'fixtures', '.bob'],
moduleNameMapper: {
'@graphql-mesh/cross-helpers': '<rootDir>/packages/cross-helpers/node.js',
...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, {
prefix: `${ROOT_DIR}/`,
}),
'formdata-node': '<rootDir>/node_modules/formdata-node/lib/cjs/index.js',
},
collectCoverage: false,
cacheDirectory: resolve(ROOT_DIR, `${CI ? '' : 'node_modules/'}.cache/jest`),
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.m?(t|j)s?$': 'babel-jest',
},
resolver: 'bob-the-bundler/jest-resolver',
testMatch,
setupFilesAfterEnv: ['<rootDir>/setup-jest.js'],
};