-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.base.ts
86 lines (68 loc) · 2.51 KB
/
jest.config.base.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
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/
import type { JestConfigWithTsJest } from 'ts-jest';
import { pathsToModuleNameMapper } from 'ts-jest';
export const baseConfig: JestConfigWithTsJest = {
// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,
// 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: ['src/**/*.ts'],
// The directory where Jest should output its coverage files
coverageDirectory: 'coverage',
// An array of regexp pattern strings used to skip coverage collection
coveragePathIgnorePatterns: [
'/node_modules/',
'/generated/',
],
// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'v8',
// A list of reporter names that Jest uses when writing coverage reports
coverageReporters: [
'lcov',
'clover',
'text',
'html',
],
// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: undefined,
// A preset that is used as a base for Jest's configuration
preset: 'ts-jest',
// A list of paths to modules that run some code to configure or set up the testing environment
setupFiles: [
'dotenv/config'
],
// The test environment that will be used for testing
testEnvironment: 'node',
// The glob patterns Jest uses to detect test files
testMatch: [
'<rootDir>/src/**/*.spec.ts'
],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: [
'.history',
'__mocks__',
'node_modules',
'generated',
],
// Default timeout of a test in milliseconds.
testTimeout: 30000,
// A map from regular expressions to paths to transformers
transform: {
'^.+\\.tsx?$': ['ts-jest', {
tsconfig: 'tsconfig.spec.json'
}]
},
// Indicates whether each individual test should be reported during the run
verbose: true
};
export function configWithResolvedModulePaths(compilerOptions: { baseUrl: string, paths: Record<string, string[]> }): JestConfigWithTsJest {
return {
...baseConfig,
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
};
}