forked from udecode/plate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.config.js
68 lines (60 loc) · 1.95 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
62
63
64
65
66
67
68
const { pathsToModuleNameMapper } = require('ts-jest');
const appRoot = require('app-root-path');
const { getJestCachePath } = require(`${appRoot}/config/cache.config`);
const packageJson = require(`${process.cwd()}/package.json`);
const packageName = packageJson.name ?? 'plate';
const {
compilerOptions: baseTsConfig,
} = require(`${process.cwd()}/tsconfig.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-plate`);
const modules = {};
Object.keys(aliases).forEach((key) => {
const value = aliases[key];
modules[`^${key}$`] = `<rootDir>/packages/${value}/src`;
});
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
displayName: packageName,
cacheDirectory: getJestCachePath(packageName),
// TODO
collectCoverageFrom: [
'packages/**/src/**/*.{ts,tsx}',
'!**/*.styles.ts*',
'!**/index.ts*',
'!**/*test*/**',
'!**/*fixture*/**',
'!**/*template*/**',
'!**/*stories*',
'!**/*.development.*',
],
globals: {
'ts-jest': {
diagnostics: true,
tsconfig: '<rootDir>/config/tsconfig.test.json',
},
},
moduleDirectories: ['node_modules'],
moduleFileExtensions: ['js', 'json', 'ts', 'tsx'],
moduleNameMapper: {
'\\.(css|less|sass|scss)$': '<rootDir>/scripts/styleMock.js',
...getTsConfigBasePaths(),
'^@udecode/plate-core$': '<rootDir>/packages/core/src',
...modules,
},
testEnvironment: 'jsdom',
testRegex: '(test|spec).tsx?$',
transform: {
'.*': ['<rootDir>/scripts/fileTransformer.js', 'ts-jest'],
},
transformIgnorePatterns: ['/node_modules/(?!react-dnd|dnd-core|@react-dnd)'],
setupFilesAfterEnv: ['<rootDir>/scripts/setupTests.ts'],
};