MCPcopy
hub / github.com/jestjs/jest / updateGlobalConfig

Function updateGlobalConfig

packages/jest-core/src/lib/updateGlobalConfig.ts:16–110  ·  view source on GitHub ↗
(
  globalConfig: Config.GlobalConfig,
  options: AllowedConfigOptions & ExtraConfigOptions = {},
)

Source from the content-addressed store, hash-verified

14>;
15
16export default function updateGlobalConfig(
17 globalConfig: Config.GlobalConfig,
18 options: AllowedConfigOptions & ExtraConfigOptions = {},
19): Config.GlobalConfig {
20 const newConfig: Config.GlobalConfig = {...globalConfig};
21
22 if (options.mode === 'watch') {
23 newConfig.watch = true;
24 newConfig.watchAll = false;
25 } else if (options.mode === 'watchAll') {
26 newConfig.watch = false;
27 newConfig.watchAll = true;
28 }
29
30 if (options.testNamePattern !== undefined) {
31 newConfig.testNamePattern = options.testNamePattern || '';
32 }
33
34 if (options.testPathPatterns !== undefined) {
35 newConfig.testPathPatterns = new TestPathPatterns(options.testPathPatterns);
36 }
37
38 newConfig.onlyChanged =
39 !newConfig.watchAll &&
40 !newConfig.testNamePattern &&
41 !newConfig.testPathPatterns.isSet();
42
43 if (typeof options.bail === 'boolean') {
44 newConfig.bail = options.bail ? 1 : 0;
45 } else if (options.bail !== undefined) {
46 newConfig.bail = options.bail;
47 }
48
49 if (options.changedSince !== undefined) {
50 newConfig.changedSince = options.changedSince;
51 }
52
53 if (options.collectCoverage !== undefined) {
54 newConfig.collectCoverage = options.collectCoverage || false;
55 }
56
57 if (options.collectCoverageFrom !== undefined) {
58 newConfig.collectCoverageFrom = options.collectCoverageFrom;
59 }
60
61 if (options.coverageDirectory !== undefined) {
62 newConfig.coverageDirectory = options.coverageDirectory;
63 }
64
65 if (options.coverageReporters !== undefined) {
66 newConfig.coverageReporters = options.coverageReporters;
67 }
68
69 if (options.findRelatedTests !== undefined) {
70 newConfig.findRelatedTests = options.findRelatedTests;
71 }
72
73 if (options.nonFlagArgs !== undefined) {

Callers 3

watchFunction · 0.85
updateConfigAndRunFunction · 0.85
onKeypressFunction · 0.85

Calls 1

isSetMethod · 0.65

Tested by

no test coverage detected