-
Notifications
You must be signed in to change notification settings - Fork 362
Expand file tree
/
Copy pathjest.config.js
More file actions
132 lines (117 loc) · 4.52 KB
/
Copy pathjest.config.js
File metadata and controls
132 lines (117 loc) · 4.52 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
const { resolve } = require('path');
const { pathsToModuleNameMapper } = require('ts-jest');
const JSON5 = require('json5');
const CI = !!process.env.CI;
const { readFileSync } = require('fs');
const { platform } = require('os');
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 displayName = 'Unit Tests';
if (process.env.E2E_TEST) {
displayName = 'E2E Tests';
}
if (process.env.INTEGRATION_TEST) {
displayName = 'Integration Tests';
}
if (process.env.LEAK_TEST) {
displayName += ' (Leak Detection)';
}
let testMatch = ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'];
if (process.env.LEAK_TEST) {
testMatch.push('!**/examples/grpc-reflection-example/**');
testMatch.push('!**/examples/sqlite-*/**');
testMatch.push('!**/examples/mongoose-*/**');
testMatch.push('!**/examples/mysql-*/**');
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)');
}
const platformName = platform();
const isLinux = platformName === 'linux';
const isWindows = platformName === 'win32';
if (process.env.E2E_TEST && process.env.CI && !isLinux) {
// TODO: containers are not starting on non-linux environments
testMatch.push('!**/e2e/auto-type-merging/**');
testMatch.push('!**/e2e/neo4j-example/**');
testMatch.push('!**/e2e/soap-demo/**');
testMatch.push('!**/e2e/mysql-employees/**');
testMatch.push('!**/e2e/opentelemetry/**');
if (isWindows) {
testMatch.push('!**/e2e/tsconfig-paths/**');
testMatch.push('!**/e2e/cjs-project/**');
}
}
const ESM_PACKAGES = [
'@neo4j/cypher-builder',
'@graphql-codegen/typescript/node_modules/auto-bind',
'auto-bind',
'commander',
'@commander-js/extra-typings',
];
/** @type {import('jest').Config} */
module.exports = {
displayName,
prettierPath: null, // not supported before Jest v30 https://github.com/jestjs/jest/issues/14305
testEnvironment: 'node',
rootDir: ROOT_DIR,
restoreMocks: true,
reporters: ['default'],
verbose: !!process.env.DEBUG,
modulePathIgnorePatterns: ['dist', 'fixtures', '.bob'],
moduleNameMapper: {
'@graphql-mesh/cross-helpers': '<rootDir>/packages/cross-helpers/node.js',
// Packages outside this repo
'@graphql-mesh/fusion-runtime':
'<rootDir>/node_modules/@graphql-mesh/fusion-runtime/dist/index.cjs',
'@graphql-mesh/transport-common':
'<rootDir>/node_modules/@graphql-mesh/transport-common/dist/index.cjs',
'@graphql-mesh/transport-http':
'<rootDir>/node_modules/@graphql-mesh/transport-http/dist/index.cjs',
'@graphql-mesh/transport-ws':
'<rootDir>/node_modules/@graphql-mesh/transport-ws/dist/index.cjs',
'@graphql-mesh/transport-http-callback':
'<rootDir>/node_modules/transport-http-callback/dist/index.cjs',
'@graphql-mesh/hmac-upstream-signature':
'<rootDir>/node_modules/@graphql-mesh/hmac-upstream-signature/dist/index.cjs',
'@graphql-mesh/opentelemetry':
'<rootDir>/node_modules/@graphql-mesh/opentelemetry/dist/index.cjs',
'@graphql-mesh/plugin-prometheus':
'<rootDir>/node_modules/@graphql-mesh/prometheus/dist/index.cjs',
'@graphql-mesh/plugin-jwt-auth':
'<rootDir>/node_modules/@graphql-mesh/plugin-jwt-auth/dist/index.cjs',
'^graphql$': '<rootDir>/node_modules/graphql/index.js',
'^lru-cache$': '<rootDir>/node_modules/lru-cache/dist/commonjs/index.js',
...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, {
prefix: `${ROOT_DIR}/`,
useESM: true,
}),
},
collectCoverage: false,
cacheDirectory: resolve(ROOT_DIR, `${CI ? '' : 'node_modules/'}.cache/jest`),
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.m?(t|j)s?$': 'babel-jest',
},
transformIgnorePatterns: [`node_modules/(?!(${ESM_PACKAGES.join('|')})/)`],
resolver: 'bob-the-bundler/jest-resolver',
testMatch,
setupFilesAfterEnv: ['<rootDir>/setup-jest.js'],
};