Repository navigation
Expand file tree
/
Copy pathjest.config.base.js
More file actions
61 lines (56 loc) · 2.38 KB
/
Copy pathjest.config.base.js
File metadata and controls
61 lines (56 loc) · 2.38 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
const path = require('path');
module.exports = {
// cacheDirectory is intentionally set per package, not here: __dirname in this base file is the
// monorepo root, so a value here would share one cache dir across every package's ts-jest
// compilation, the exact race this setup avoids.
clearMocks: true,
collectCoverage: true,
// NOTE: rootDir is per-package (packages/canc-*) both for standalone `jest` runs (npm test via
// lerna) and for root multi-project runs (each project's rootDir = its package dir). Glob must
// be relative to package rootDir, NOT prefixed with 'packages/*' (that never matches, coverage
// silently collected 0 files, threshold never enforced; fixed).
collectCoverageFrom: [
'src/**/*.js',
'src/**/*.jsx',
'src/**/*.ts',
'src/**/*.tsx',
'!**/__mocks__/**',
'!**/__tests__/**',
'!**/*.spec.ts',
'!**/build/**',
'!**/dist/**',
'!**/node_modules/**',
'!**/~~*',
'!**/*~~',
],
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: ['/node_modules/', '/~~', '~~$'],
globals: {},
// lerna runs two packages at once, so two jest runs together stay near the core count
maxWorkers: '50%',
// `<rootDir>` here is per-package (see rootDir note above, same hazard as
// collectCoverageFrom). A package that imports a sibling @cancjs/* package by name (e.g.
// canc-coroutine importing @cancjs/promise) resolved to `<own-pkg>/packages/canc-promise/src`,
// which doesn't exist. Anchor to the monorepo root (this file's own directory, always the repo
// root regardless of which package's rootDir jest is invoked with) instead of the `<rootDir>`
// token.
// Order matters: jest tries mappers in sequence, and the general rule below would send
// @cancjs/server-node to packages/canc-server-node/src, one directory level too shallow.
moduleNameMapper: {
'^@cancjs/server-(.*)$': path.join(__dirname, 'packages/canc-server/canc-server-$1/src'),
'^@cancjs/(.*)$': path.join(__dirname, 'packages/canc-$1/src'),
},
modulePathIgnorePatterns: ['/~~', '~~/'],
roots: ['<rootDir>/src'],
testEnvironment: 'node',
// GC canaries run serially with --expose-gc, in `npm run test:canary` only
testPathIgnorePatterns: ['/node_modules/', '/~~', '~~/', '/leak-canaries\\.spec\\.ts$'],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: 'tsconfig.test.json',
},
],
},
};