-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjest.config.js
More file actions
58 lines (52 loc) · 2.06 KB
/
Copy pathjest.config.js
File metadata and controls
58 lines (52 loc) · 2.06 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
const path = require('path');
const { lstatSync, readdirSync } = require('fs');
const PACKAGE_NAME_SPACE = '@namespace';
const ROOT_REPO = path.resolve(__dirname);
const ROOT_JEST_CONFIG_FOLDER = `${ROOT_REPO}/config/jest`;
// get listing of packages in the mono repo
const PACKAGE_FOLDER = `${ROOT_REPO}/packages`;
const packages = readdirSync(PACKAGE_FOLDER).filter((name) => {
const packageFolders = path.join(PACKAGE_FOLDER, name);
return lstatSync(packageFolders).isDirectory();
});
const moduleNameMapper = {
...packages.reduce(
(acc, name) => ({
...acc,
[`${PACKAGE_NAME_SPACE}/${name}(.*)$`]: `${PACKAGE_FOLDER}/./${name}/src/$1`,
}),
{},
),
};
module.exports = {
testEnvironment: 'jsdom',
transform: {
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': `${ROOT_JEST_CONFIG_FOLDER}/fileTransform.js`,
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$': `${ROOT_JEST_CONFIG_FOLDER}/babelTransform.js`,
'^.+\\.css$': `${ROOT_JEST_CONFIG_FOLDER}/cssTransform.js`,
},
// testRegex: '(/test/.*.(test|spec)).(jsx?|tsx?)$',
collectCoverage: true,
coveragePathIgnorePatterns: ['(test/.*.mock).(jsx?|tsx?)$'],
verbose: true,
projects: ['<rootDir>'],
coverageDirectory: '<rootDir>/coverage/',
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'],
moduleFileExtensions: ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'],
moduleNameMapper: {
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
...moduleNameMapper,
},
modulePaths: [],
resetMocks: true,
roots: ['<rootDir>/src'],
setupFiles: ['react-app-polyfill/jsdom'],
setupFilesAfterEnv: [`${ROOT_JEST_CONFIG_FOLDER}/setupTests.ts`],
testMatch: ['<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}', '<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}'],
testRunner: `${ROOT_REPO}/node_modules/jest-circus/runner.js`,
transformIgnorePatterns: [
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$',
'^.+\\.module\\.(css|sass|scss)$',
],
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
};