-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
jest.config.base.js
59 lines (55 loc) · 2.14 KB
/
jest.config.base.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
const path = require('node:path');
module.exports = (dir, env = 'jsdom') => {
const package = require(`${dir}/package.json`);
const setupFilesAfterEnv = [];
if (env === 'jsdom') {
setupFilesAfterEnv.push(path.join(__dirname, '/resources/test.config.js'));
}
return {
globals: {
'ts-jest': {
tsConfig: `${__dirname}/resources/tsconfig.base.esm.json`,
},
},
clearMocks: true,
collectCoverage: true,
coverageDirectory: `${__dirname}/coverage/jest`,
setupFilesAfterEnv,
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'identity-obj-proxy',
'\\.(css|less)$': 'identity-obj-proxy',
'^graphql-language-service-([^/]+)': `${__dirname}/packages/graphql-language-service/src/$1`,
'^graphql-language-([^/]+)': `${__dirname}/packages/graphql-language-$1/src`,
'^@graphiql\\/([^/]+)': `${__dirname}/packages/graphiql-$1/src`,
'^@graphiql-plugins\\/([^/]+)': `${__dirname}/plugins/$1/src`,
'^codemirror-graphql\\/esm([^]+)': `${__dirname}/packages/codemirror-graphql/src/$1`,
'^codemirror-graphql\\/cjs([^]+)': `${__dirname}/packages/codemirror-graphql/src/$1`,
// relies on compilation
'^cm6-graphql\\/src\\/([^]+)': `${__dirname}/packages/cm6-graphql/dist/$1`,
'^example-([^/]+)': `${__dirname}/examples/$1/src`,
'^-!svg-react-loader.*$': '<rootDir>/resources/jest/svgImportMock.js',
// because of the svelte compiler's export patterns i guess?
'svelte/compiler': `${__dirname}/node_modules/svelte/compiler.cjs`,
},
testMatch: ['**/*[-.](spec|test).[jt]s?(x)', '!**/cypress/**'],
testEnvironment: env,
testPathIgnorePatterns: ['node_modules', 'dist', 'cypress'],
collectCoverageFrom: ['**/src/**/*.{js,jsx,ts,tsx}'],
transformIgnorePatterns: ['node_modules/(!@astrojs/compiler)'],
coveragePathIgnorePatterns: [
'dist',
'esm',
'node_modules',
'__tests__',
'resources',
'examples',
'.d.ts',
'types.ts',
],
roots: ['<rootDir>'],
rootDir: dir,
name: package.name,
displayName: package.name,
};
};