-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
jest.config.scripts.js
88 lines (70 loc) · 2.97 KB
/
jest.config.scripts.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*
* NOTE:
* This config uses `babel-jest` due to ESM- / TypeScript-related incompatibilities with our
* current version (`^27`) of `jest` and `ts-jest`. We can switch to `ts-jest` once we have
* migrated our Jest dependencies to version `>=29`.
*/
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,
},
},
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
// This ensures that Babel can resolve subpath exports correctly.
moduleNameMapper: {
'^@metamask/utils/(.+)$': [
'<rootDir>/node_modules/@metamask/utils/dist/$1.cjs',
],
},
// Disabled due to use of 'transform' below.
// // A preset that is used as a base for Jest's configuration
// preset: 'ts-jest',
// "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,
// A map from regular expressions to paths to transformers
transform: {
'\\.[jt]sx?$': 'babel-jest',
},
};