-
-
Notifications
You must be signed in to change notification settings - Fork 748
/
jest.config.cjs
78 lines (71 loc) · 2.45 KB
/
jest.config.cjs
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
const appRoot = require('app-root-path');
const { pathsToModuleNameMapper } = require('ts-jest');
const packageJson = require(`${process.cwd()}/package.json`);
const packageName = packageJson.name ?? 'plate';
const { compilerOptions: baseTsConfig } = require(
`${appRoot}/config/tsconfig.test.json`
);
// Take the paths from tsconfig automatically from base tsconfig.json
// @link https://kulshekhar.github.io/ts-jest/docs/paths-mapping
const getTsConfigBasePaths = () => {
return baseTsConfig.paths
? pathsToModuleNameMapper(baseTsConfig.paths, {
prefix: '<rootDir>/',
})
: {};
};
const aliases = require(`${appRoot}/config/aliases`);
const modules = {};
Object.keys(aliases).forEach((key) => {
const value = aliases[key];
modules[`^${key}$`] = `<rootDir>/packages/${value}/src`;
modules[`^${key}/react$`] = `<rootDir>/packages/${value}/src/react`;
});
/** @type {import('ts-jest').JestConfigWithTsJest} */
// @ts-check
module.exports = {
collectCoverageFrom: [
'packages/**/src/**/*.{ts,tsx}',
'!**/*.styles.ts*',
'!**/index.ts*',
'!**/*test*/**',
'!**/*fixture*/**',
'!**/*template*/**',
'!**/*stories*',
'!**/*.development.*',
],
coveragePathIgnorePatterns: ['/node_modules/', String.raw`\.d\.ts$`],
displayName: packageName,
moduleDirectories: ['node_modules'],
moduleFileExtensions: ['js', 'json', 'ts', 'tsx'],
moduleNameMapper: {
'\\.(css|less|sass|scss)$': '<rootDir>/scripts/styleMock.cjs',
...getTsConfigBasePaths(),
...modules,
},
preset: 'ts-jest',
setupFilesAfterEnv: ['<rootDir>/scripts/setupTests.ts'],
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['/playwright/', '/packages/cli/'],
testRegex: '(test|spec).tsx?$',
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
transformIgnorePatterns: [
'/node_modules/(?!(' +
'react-dnd|dnd-core|@react-dnd|react-dnd-html5-backend|react-tweet|unified' +
'|remark-.*' +
'|mdast-.*' +
'|micromark.*' +
'|unist-.*' +
'|markdown-table' +
// '|markdown-.*' +
'|mdast-util-to-markdown|zwitch|longest-streak|unist-util-visit|mdast-util-phrasing' +
'|escape-string-regexp|micromark-util-decode-string|decode-named-character-reference' +
'|ccount|bail|devlop|is-plain-obj|trough|vfile|vfile-message' +
'|is-reference|is-buffer|@types/unist' +
'|unist-util-stringify-position|mdast-util-from-markdown|mdast-util-to-string' +
')/)',
],
watchman: false,
};