-
Notifications
You must be signed in to change notification settings - Fork 26
/
jest.config.ts
92 lines (77 loc) · 2.82 KB
/
jest.config.ts
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
90
91
92
import * as path from 'path';
import type { Config } from '@jest/types';
const isCI = process.env.CI === 'true';
const config: Config.InitialOptions = {
displayName: 'pushin',
rootDir: path.resolve('.'),
preset: 'ts-jest',
/**
* A set of global variables that need to be available in all test environments.
*/
globals: {
'ts-jest': {
allowSyntheticDefaultImports: true,
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
transform: {
'^.+\\.spec.ts$': 'ts-jest',
},
/**
* By default, Jest runs all tests and produces all errors into the console upon completion.
* The bail config option can be used here to have Jest stop running tests after n failures.
* Setting bail to true is the same as setting bail to 1
*/
bail: true,
/**
* Indicates whether the coverage information should be collected while executing the test.
* Because this retrofits all executed files with coverage collection statements,
* it may significantly slow down your tests.
*/
collectCoverage: isCI,
/**
* An array of glob patterns indicating a set of files for which coverage
* information should be collected. If a file matches the specified glob pattern,
* coverage information will be collected for it even if no tests exist for this file and
* it's never required in the test suite.
*/
collectCoverageFrom: [
'src/**/*.ts',
'!src/index.ts|src/constants.ts|src/helpers.ts',
],
/**
* A list of reporter names that Jest uses when writing coverage reports.
* Any istanbul reporter can be used.
* https://github.com/istanbuljs/istanbuljs/tree/master/packages/istanbul-reports/lib
*/
coverageReporters: ['json', 'lcovonly', 'lcov', 'text', 'html'],
/**
* The glob patterns Jest uses to detect test files.
*/
testMatch: ['<rootDir>/test/**/*.spec.ts'],
/**
* Indicates whether each individual test should be reported during the run.
* All errors will also still be shown on the bottom after execution.
*/
verbose: true,
/**
* The directory where Jest should store its cached dependency information.
*/
cacheDirectory: '<rootDir>/.cache',
/**
* By default, each test file gets its own independent module registry.
* Enabling resetModules goes a step further and resets the module registry before running
* each individual test. This is useful to isolate modules for every test so that local
* module state doesn't conflict between tests. This can be done programmatically
* using jest.resetModules().
*/
resetModules: true,
/**
* Automatically clear mock calls and instances between every test.
* Equivalent to calling jest.clearAllMocks() between each test.
* This does not remove any mock implementation that may have been provided.
*/
clearMocks: true,
testEnvironment: 'node',
};
export default config;