-
Notifications
You must be signed in to change notification settings - Fork 229
Expand file tree
/
Copy pathjest.unit.config.js
More file actions
73 lines (69 loc) · 2.14 KB
/
jest.unit.config.js
File metadata and controls
73 lines (69 loc) · 2.14 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// https://jestjs.io/docs/configuration
const path = require('path');
const { lstatSync, readdirSync } = require('fs');
// get listing of packages in the mono repo
const basePath = path.resolve(__dirname, 'packages');
const packages = readdirSync(basePath).filter((name) => {
return lstatSync(path.join(basePath, name)).isDirectory();
});
// Installing third-party modules by tnpm or cnpm will name modules with underscore as prefix.
// In this case _{module} is also necessary.
const esm = ['internmap', 'd3-*', 'lodash-es']
.map((d) => `_${d}|${d}`)
.join('|');
// @see https://blog.ah.technology/a-guide-through-the-wild-wild-west-of-setting-up-a-mono-repo-part-2-adding-jest-with-a-breeze-16e08596f0de
const moduleNameMapper = {
...packages.reduce(
(acc, name) => ({
...acc,
[`@antv/${name}$`]: `<rootDir>/packages/${name}/src/`,
}),
{},
),
};
/** @type {import('jest').Config} */
module.exports = {
testTimeout: 100000,
moduleNameMapper: moduleNameMapper,
collectCoverageFrom: [
'<rootDir>/packages/g/src/**/*.{ts,tsx}',
'<rootDir>/packages/g-lite/src/**/*.{ts,tsx}',
//
'<rootDir>/packages/g-canvas/src/**/*.{ts,tsx}',
//
'<rootDir>/packages/g-svg/src/**/*.{ts,tsx}',
],
coveragePathIgnorePatterns: ['/node_modules/', '/__tests__/'],
coverageDirectory: 'coverage',
coverageReporters: ['clover', 'json', 'lcov', 'text'],
// coverageThreshold: {
// global: {
// branches: 80,
// functions: 80,
// lines: 80,
// statements: 80,
// },
// },
testEnvironment: 'jsdom',
testMatch: [
'<rootDir>/__tests__/unit/**/*/*.spec.+(ts|tsx|js)',
'<rootDir>/__tests__/unit/*.spec.+(ts|tsx|js)',
],
testPathIgnorePatterns: process.env.CI ? ['<rootDir>/__tests__/main.ts'] : [],
preset: 'ts-jest',
transform: {
'^.+\\.[tj]s$': [
'ts-jest',
{
tsconfig: {
allowJs: true,
target: 'esnext',
esModuleInterop: true,
},
},
],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
modulePathIgnorePatterns: ['dist'],
transformIgnorePatterns: [`<rootDir>/node_modules/(?!(?:.pnpm/)?(${esm}))`],
};