-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
/
jestConfig.js
165 lines (152 loc) · 4.53 KB
/
jestConfig.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/**
* Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
*/
'use strict';
const chalk = require('chalk');
const os = require('os');
const path = require('path');
const NODE_MODULES = path.sep + 'node_modules' + path.sep;
const replacePathSepForRegex = (string: string) => {
if (path.sep === '\\') {
return string.replace(/(\/|\\(?!\.))/g, '\\\\');
}
return string;
};
const NODE_MODULES_REGEXP = replacePathSepForRegex(NODE_MODULES);
const defaultConfig = {
automock: false,
bail: false,
browser: false,
cacheDirectory: path.join(os.tmpdir(), 'jest'),
coveragePathIgnorePatterns: [NODE_MODULES_REGEXP],
coverageReporters: ['json', 'text', 'lcov', 'clover'],
expand: false,
globals: {},
haste: {
providesModuleNodeModules: [],
},
mocksPattern: '__mocks__',
moduleDirectories: ['node_modules'],
moduleFileExtensions: [
'js',
'json',
'jsx',
'node',
],
moduleNameMapper: {},
modulePathIgnorePatterns: [],
noStackTrace: false,
notify: false,
preset: null,
resetMocks: false,
resetModules: false,
snapshotSerializers: [],
testEnvironment: 'jest-environment-jsdom',
testPathDirs: ['<rootDir>'],
testPathIgnorePatterns: [NODE_MODULES_REGEXP],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$',
testResultsProcessor: null,
testURL: 'about:blank',
timers: 'real',
transformIgnorePatterns: [NODE_MODULES_REGEXP],
useStderr: false,
verbose: null,
watch: false,
};
const validConfig = {
automock: false,
bail: false,
browser: false,
cache: true,
cacheDirectory: '/tmp/user/jest',
collectCoverage: true,
collectCoverageFrom: ['src', '!public'],
collectCoverageOnlyFrom: {
'<rootDir>/this-directory-is-covered/covered.js': true,
},
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: [NODE_MODULES_REGEXP],
coverageReporters: ['json', 'text', 'lcov', 'clover'],
coverageThreshold: {
global: {
branches: 50,
},
},
expand: false,
forceExit: false,
globals: {},
haste: {
providesModuleNodeModules: ['react', 'react-native'],
},
logHeapUsage: true,
logTransformErrors: true,
mocksPattern: '__mocks__',
moduleDirectories: ['node_modules'],
moduleFileExtensions: ['js', 'json', 'jsx', 'node'],
moduleLoader: '<rootDir>',
moduleNameMapper: {
'^React$': '<rootDir>/node_modules/react',
},
modulePathIgnorePatterns: ['<rootDir>/build/'],
modulePaths: ['/shared/vendor/modules'],
name: 'string',
noStackTrace: false,
notify: false,
preset: 'react-native',
resetMocks: false,
resetModules: false,
rootDir: '/',
setupFiles: ['<rootDir>/setup.js'],
setupTestFrameworkScriptFile: '<rootDir>/testSetupFile.js',
silent: true,
snapshotSerializers: ['my-serializer-module'],
testEnvironment: 'jest-environment-jsdom',
testNamePattern: 'test signature',
testPathDirs: ['<rootDir>'],
testPathIgnorePatterns: [NODE_MODULES_REGEXP],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$',
testResultsProcessor: 'processor-node-module',
testRunner: 'jasmine2',
testURL: 'about:blank',
timers: 'real',
transform: {
'^.+\\.js$': '<rootDir>/preprocessor.js',
},
transformIgnorePatterns: [NODE_MODULES_REGEXP],
unmockedModulePathPatterns: ['mock'],
updateSnapshot: true,
useStderr: false,
verbose: false,
watch: false,
watchman: true,
};
const format = (value: string) => require('pretty-format')(value, {min: true});
/* eslint-disable max-len */
const deprecatedConfig = {
preprocessorIgnorePatterns: (config: Object) =>
` Option ${chalk.bold('preprocessorIgnorePatterns')} was replaced by ${chalk.bold('transformIgnorePatterns')}, which support multiple preprocessors.
Jest now treats your current configuration as:
{
${chalk.bold('"transformIgnorePatterns"')}: ${chalk.bold(`${format(config.preprocessorIgnorePatterns)}`)}
}
Please update your configuration.`,
scriptPreprocessor: (config: Object) =>
` Option ${chalk.bold('scriptPreprocessor')} was replaced by ${chalk.bold('transform')}, which support multiple preprocessors.
Jest now treats your current configuration as:
{
${chalk.bold('"transform"')}: ${chalk.bold(`{".*": ${format(config.scriptPreprocessor)}}`)}
}
Please update your configuration.`,
};
/* eslint-enable max-len */
module.exports = {
defaultConfig,
deprecatedConfig,
validConfig,
};