forked from udecode/plate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.cjs
64 lines (57 loc) · 1.81 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
const { pathsToModuleNameMapper } = require('ts-jest');
const appRoot = require('app-root-path');
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`;
});
/** @type {import('ts-jest').JestConfigWithTsJest} */
//@ts-check
module.exports = {
displayName: packageName,
collectCoverageFrom: [
'packages/**/src/**/*.{ts,tsx}',
'!**/*.styles.ts*',
'!**/index.ts*',
'!**/*test*/**',
'!**/*fixture*/**',
'!**/*template*/**',
'!**/*stories*',
'!**/*.development.*',
],
moduleDirectories: ['node_modules'],
moduleFileExtensions: ['js', 'json', 'ts', 'tsx'],
moduleNameMapper: {
'\\.(css|less|sass|scss)$': '<rootDir>/scripts/styleMock.cjs',
...getTsConfigBasePaths(),
// '^better-plate-core$': '<rootDir>/packages/core/src',
...modules,
},
preset: 'ts-jest',
testEnvironment: 'jsdom',
testRegex: '(test|spec).tsx?$',
testPathIgnorePatterns: ['/playwright/'],
transform: {
'^.+\\.(t|j)sx?$': '@swc/jest',
},
setupFilesAfterEnv: ['<rootDir>/scripts/setupTests.ts'],
transformIgnorePatterns: [
'/node_modules/(?!(react-dnd|dnd-core|@react-dnd|react-dnd-html5-backend|react-tweet)/)',
],
watchman: false,
};