-
-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathjest.config.scripts.cjs
More file actions
89 lines (70 loc) · 3.03 KB
/
Copy pathjest.config.scripts.cjs
File metadata and controls
89 lines (70 loc) · 3.03 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/
module.exports = {
// Indicates whether the coverage information should be collected while executing the test
collectCoverage: true,
// An array of glob patterns indicating a set of files for which coverage information should be collected
collectCoverageFrom: ['<rootDir>/scripts/**/*.ts'],
// The directory where Jest should output its coverage files
coverageDirectory: '<rootDir>/scripts/coverage',
// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: ['/package-template/'],
// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'babel',
// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: ['text', 'html', 'json-summary'],
// An object that configures minimum threshold enforcement for coverage results
// <rootDir> does not work here.
coverageThreshold: {
'./scripts/create-package/**/*.ts': {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
moduleNameMapper: {
// Strip .js extensions from relative imports so Jest resolves them to
// the TypeScript source files.
'^(\\.{1,2}/.+)\\.js$': '$1',
// `@metamask/utils` lives in this repo, so resolve it to its source rather
// than to a build that may not exist yet.
// NOTE: This must be synchronized with the `paths` option in `tsconfig.json`.
'^@metamask/utils/node$': ['<rootDir>/packages/utils/src/node.ts'],
'^@metamask/utils$': ['<rootDir>/packages/utils/src/index.ts'],
'^uuid$': require.resolve('uuid'),
},
preset: 'ts-jest',
// Unlike the packages, the scripts use `import.meta`, which has no CommonJS
// equivalent, so their tests run as ESM. Jest only treats TypeScript as ESM
// when the extension is listed here.
extensionsToTreatAsEsm: ['.ts', '.mts'],
transform: {
'^.+\\.m?tsx?$': ['ts-jest', { useESM: true }],
},
// "resetMocks" resets all mocks, including mocked modules, to jest.fn(),
// between each test case.
resetMocks: true,
// "restoreMocks" restores all mocks created using jest.spyOn to their
// original implementations, between each test. It does not affect mocked
// modules.
restoreMocks: true,
setupFilesAfterEnv: ['./tests/scripts-setup.ts'],
// The test environment that will be used for testing
testEnvironment: 'node',
// Options that will be passed to the testEnvironment
testEnvironmentOptions: {
customExportConditions: ['node', 'node-addons'],
},
// The glob patterns Jest uses to detect test files
testMatch: [
'<rootDir>/scripts/**/__tests__/**/*.[jt]s?(x)',
'<rootDir>/scripts/**/?(*.)+(spec|test).[tj]s?(x)',
],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ['/package-template/'],
// Default timeout of a test in milliseconds.
testTimeout: 5000,
};