-
-
Notifications
You must be signed in to change notification settings - Fork 818
/
jest.config.js
61 lines (52 loc) · 1.74 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
const { resolve } = require('path');
const { pathsToModuleNameMapper } = require('ts-jest');
const CI = !!process.env.CI;
const ROOT_DIR = __dirname;
const TSCONFIG = resolve(ROOT_DIR, 'tsconfig.json');
const tsconfig = require(TSCONFIG);
const ESM_PACKAGES = ['graphql', 'graphql-upload', 'fs-capacitor'];
const modulePathIgnorePatterns = ['dist', 'test-assets', 'test-files', 'fixtures', '.bob'];
// Higher versions have only ESM support so we're good if import fails in CJS here
try {
const { versionInfo } = require('graphql');
if (versionInfo.major < 16) {
modulePathIgnorePatterns.push('federation');
}
} catch (e) {}
const externalToolsPackages = [
'@graphql-tools/batch-delegate',
'@graphql-tools/batch-execute',
'@graphql-tools/delegate',
'@graphql-tools/stitch',
'@graphql-tools/wrap',
'@graphql-tools/executor-http',
'@graphql-tools/executor-graphql-ws',
];
const externalModulesMapper = {};
externalToolsPackages.forEach(mod => {
externalModulesMapper[`^${mod}$`] = require.resolve(mod);
});
module.exports = {
testEnvironment: 'node',
rootDir: ROOT_DIR,
prettierPath: null, // disable prettier for inline snapshots
restoreMocks: true,
reporters: ['default'],
modulePathIgnorePatterns,
moduleNameMapper: {
...externalModulesMapper,
...pathsToModuleNameMapper(tsconfig.compilerOptions.paths, {
prefix: `${ROOT_DIR}/`,
}),
...externalModulesMapper,
},
collectCoverage: false,
cacheDirectory: resolve(ROOT_DIR, `${CI ? '' : 'node_modules/'}.cache/jest`),
transform: {
'^.+\\.mjs?$': 'babel-jest',
'^.+\\.ts?$': 'babel-jest',
'^.+\\.js$': 'babel-jest',
},
transformIgnorePatterns: [`node_modules/(?!(${ESM_PACKAGES.join('|')})/)`],
resolver: 'bob-the-bundler/jest-resolver',
};