Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5fbe238

Browse files
committed
Move all default values into jest-config
Fixes #8826
1 parent 6c64c19 commit 5fbe238

File tree

8 files changed

+23
-55
lines changed

8 files changed

+23
-55
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
- `[expect]` [**BREAKING**] Make `toContain` more strict with the received type ([#10119](https://github.com/facebook/jest/pull/10119))
2222
- `[jest-circus]` Fixed the issue of beforeAll & afterAll hooks getting executed even if it is inside a skipped `describe` block [#10451](https://github.com/facebook/jest/issues/10451)
2323
- `[jest-circus]` Fix `testLocation` on Windows when using `test.each` ([#10871](https://github.com/facebook/jest/pull/10871))
24+
- `[jest-cli, jest-config, jest-types]` Move all default values into `jest-config` ([#9924](https://github.com/facebook/jest/pull/9924))
2425
- `[jest-console]` `console.dir` now respects the second argument correctly ([#10638](https://github.com/facebook/jest/pull/10638))
2526
- `[jest-environment-jsdom]` Use inner realm’s `ArrayBuffer` constructor ([#10885](https://github.com/facebook/jest/pull/10885))
2627
- `[jest-globals]` [**BREAKING**] Disallow return values other than a `Promise` from hooks and tests ([#10512](https://github.com/facebook/jest/pull/10512))

packages/jest-cli/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"exit": "^0.1.2",
1818
"graceful-fs": "^4.2.4",
1919
"import-local": "^3.0.2",
20-
"is-ci": "^2.0.0",
2120
"jest-config": "^26.6.3",
2221
"jest-util": "^26.6.2",
2322
"jest-validate": "^26.6.2",
@@ -28,7 +27,6 @@
2827
"@jest/test-utils": "^26.6.2",
2928
"@types/exit": "^0.1.30",
3029
"@types/graceful-fs": "^4.1.3",
31-
"@types/is-ci": "^2.0.0",
3230
"@types/prompts": "^2.0.1",
3331
"@types/yargs": "^15.0.0"
3432
},

packages/jest-cli/src/cli/args.ts

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import isCI = require('is-ci');
98
import type {Config} from '@jest/types';
109
import {constants, isJSONString} from 'jest-config';
1110

@@ -89,37 +88,33 @@ export const usage =
8988
'Usage: $0 [--config=<pathToConfigFile>] [TestPathPattern]';
9089
export const docs = 'Documentation: https://jestjs.io/';
9190

91+
// The default values are all set in jest-config
9292
export const options = {
9393
all: {
94-
default: undefined,
9594
description:
9695
'The opposite of `onlyChanged`. If `onlyChanged` is set by ' +
9796
'default, running jest with `--all` will force Jest to run all tests ' +
9897
'instead of running only tests related to changed files.',
9998
type: 'boolean',
10099
},
101100
automock: {
102-
default: undefined,
103101
description: 'Automock all files by default.',
104102
type: 'boolean',
105103
},
106104
bail: {
107105
alias: 'b',
108-
default: undefined,
109106
description:
110107
'Exit the test suite immediately after `n` number of failing tests.',
111108
type: 'boolean',
112109
},
113110
browser: {
114-
default: undefined,
115111
description:
116112
'Respect the "browser" field in package.json ' +
117113
'when resolving modules. Some packages export different versions ' +
118114
'based on whether they are operating in node.js or a browser.',
119115
type: 'boolean',
120116
},
121117
cache: {
122-
default: undefined,
123118
description:
124119
'Whether to use the transform cache. Disable the cache ' +
125120
'using --no-cache.',
@@ -132,7 +127,6 @@ export const options = {
132127
type: 'string',
133128
},
134129
changedFilesWithAncestor: {
135-
default: undefined,
136130
description:
137131
'Runs tests related to the current changes and the changes made in the ' +
138132
'last commit. Behaves similarly to `--onlyChanged`.',
@@ -147,29 +141,25 @@ export const options = {
147141
type: 'string',
148142
},
149143
ci: {
150-
default: isCI,
151144
description:
152145
'Whether to run Jest in continuous integration (CI) mode. ' +
153146
'This option is on by default in most popular CI environments. It will ' +
154147
'prevent snapshots from being written unless explicitly requested.',
155148
type: 'boolean',
156149
},
157150
clearCache: {
158-
default: undefined,
159151
description:
160152
'Clears the configured Jest cache directory and then exits. ' +
161153
'Default directory can be found by calling jest --showConfig',
162154
type: 'boolean',
163155
},
164156
clearMocks: {
165-
default: undefined,
166157
description:
167158
'Automatically clear mock calls and instances between every ' +
168159
'test. Equivalent to calling jest.clearAllMocks() between each test.',
169160
type: 'boolean',
170161
},
171162
collectCoverage: {
172-
default: undefined,
173163
description: 'Alias for --coverage.',
174164
type: 'boolean',
175165
},
@@ -185,14 +175,12 @@ export const options = {
185175
type: 'array',
186176
},
187177
color: {
188-
default: undefined,
189178
description:
190179
'Forces test results output color highlighting (even if ' +
191180
'stdout is not a TTY). Set to false if you would like to have no colors.',
192181
type: 'boolean',
193182
},
194183
colors: {
195-
default: undefined,
196184
description: 'Alias for `--color`.',
197185
type: 'boolean',
198186
},
@@ -206,7 +194,6 @@ export const options = {
206194
type: 'string',
207195
},
208196
coverage: {
209-
default: undefined,
210197
description:
211198
'Indicates that test coverage information should be ' +
212199
'collected and reported in the output.',
@@ -242,20 +229,17 @@ export const options = {
242229
type: 'string',
243230
},
244231
debug: {
245-
default: undefined,
246232
description: 'Print debugging info about your jest config.',
247233
type: 'boolean',
248234
},
249235
detectLeaks: {
250-
default: false,
251236
description:
252237
'**EXPERIMENTAL**: Detect memory leaks in tests. After executing a ' +
253238
'test, it will try to garbage collect the global object used, and fail ' +
254239
'if it was leaked',
255240
type: 'boolean',
256241
},
257242
detectOpenHandles: {
258-
default: false,
259243
description:
260244
'Print out remaining open handles preventing Jest from exiting at the ' +
261245
'end of a test run. Implies `runInBand`.',
@@ -269,18 +253,15 @@ export const options = {
269253
type: 'string',
270254
},
271255
errorOnDeprecated: {
272-
default: false,
273256
description: 'Make calling deprecated APIs throw helpful error messages.',
274257
type: 'boolean',
275258
},
276259
expand: {
277260
alias: 'e',
278-
default: undefined,
279261
description: 'Use this flag to show full diffs instead of a patch.',
280262
type: 'boolean',
281263
},
282264
filter: {
283-
default: undefined,
284265
description:
285266
'Path to a module exporting a filtering function. This method receives ' +
286267
'a list of tests which can be manipulated to exclude tests from ' +
@@ -289,15 +270,13 @@ export const options = {
289270
type: 'string',
290271
},
291272
findRelatedTests: {
292-
default: undefined,
293273
description:
294274
'Find related tests for a list of source files that were ' +
295275
'passed in as arguments. Useful for pre-commit hook integration to run ' +
296276
'the minimal amount of tests necessary.',
297277
type: 'boolean',
298278
},
299279
forceExit: {
300-
default: undefined,
301280
description:
302281
'Force Jest to exit after all tests have completed running. ' +
303282
'This is useful when resources set up by test code cannot be ' +
@@ -332,44 +311,38 @@ export const options = {
332311
type: 'boolean',
333312
},
334313
json: {
335-
default: undefined,
336314
description:
337315
'Prints the test results in JSON. This mode will send all ' +
338316
'other test output and user messages to stderr.',
339317
type: 'boolean',
340318
},
341319
lastCommit: {
342-
default: undefined,
343320
description:
344321
'Run all tests affected by file changes in the last commit made. ' +
345322
'Behaves similarly to `--onlyChanged`.',
346323
type: 'boolean',
347324
},
348325
listTests: {
349-
default: false,
350326
description:
351327
'Lists all tests Jest will run given the arguments and ' +
352328
'exits. Most useful in a CI system together with `--findRelatedTests` ' +
353329
'to determine the tests Jest will run based on specific files',
354330
type: 'boolean',
355331
},
356332
logHeapUsage: {
357-
default: undefined,
358333
description:
359334
'Logs the heap usage after every test. Useful to debug ' +
360335
'memory leaks. Use together with `--runInBand` and `--expose-gc` in ' +
361336
'node.',
362337
type: 'boolean',
363338
},
364339
mapCoverage: {
365-
default: undefined,
366340
description:
367341
'Maps code coverage reports against original source code ' +
368342
'when transformers supply source maps.\n\nDEPRECATED',
369343
type: 'boolean',
370344
},
371345
maxConcurrency: {
372-
default: 5,
373346
description:
374347
'Specifies the maximum number of tests that are allowed to run' +
375348
'concurrently. This only affects tests using `test.concurrent`.',
@@ -423,23 +396,19 @@ export const options = {
423396
type: 'array',
424397
},
425398
noStackTrace: {
426-
default: undefined,
427399
description: 'Disables stack trace in test results output',
428400
type: 'boolean',
429401
},
430402
notify: {
431-
default: undefined,
432403
description: 'Activates notifications for test results.',
433404
type: 'boolean',
434405
},
435406
notifyMode: {
436-
default: 'failure-change',
437407
description: 'Specifies when notifications will appear for test results.',
438408
type: 'string',
439409
},
440410
onlyChanged: {
441411
alias: 'o',
442-
default: undefined,
443412
description:
444413
'Attempts to identify which tests to run based on which ' +
445414
"files have changed in the current repository. Only works if you're " +
@@ -448,7 +417,6 @@ export const options = {
448417
},
449418
onlyFailures: {
450419
alias: 'f',
451-
default: undefined,
452420
description: 'Run tests that failed in the previous execution.',
453421
type: 'boolean',
454422
},
@@ -459,7 +427,6 @@ export const options = {
459427
type: 'string',
460428
},
461429
passWithNoTests: {
462-
default: false,
463430
description:
464431
'Will not fail if no tests are found (for example while using `--testPathPattern`.)',
465432
type: 'boolean',
@@ -469,7 +436,6 @@ export const options = {
469436
type: 'string',
470437
},
471438
prettierPath: {
472-
default: undefined,
473439
description: 'The path to the "prettier" module used for inline snapshots.',
474440
type: 'string',
475441
},
@@ -486,14 +452,12 @@ export const options = {
486452
type: 'array',
487453
},
488454
resetMocks: {
489-
default: undefined,
490455
description:
491456
'Automatically reset mock state between every test. ' +
492457
'Equivalent to calling jest.resetAllMocks() between each test.',
493458
type: 'boolean',
494459
},
495460
resetModules: {
496-
default: undefined,
497461
description:
498462
'If enabled, the module registry for every test file will ' +
499463
'be reset before running each individual test.',
@@ -504,7 +468,6 @@ export const options = {
504468
type: 'string',
505469
},
506470
restoreMocks: {
507-
default: undefined,
508471
description:
509472
'Automatically restore mock state and implementation between every test. ' +
510473
'Equivalent to calling jest.restoreAllMocks() between each test.',
@@ -525,7 +488,6 @@ export const options = {
525488
},
526489
runInBand: {
527490
alias: 'i',
528-
default: undefined,
529491
description:
530492
'Run all tests serially in the current process (rather than ' +
531493
'creating a worker pool of child processes that run tests). This ' +
@@ -534,7 +496,6 @@ export const options = {
534496
type: 'boolean',
535497
},
536498
runTestsByPath: {
537-
default: false,
538499
description:
539500
'Used when provided patterns are exact file paths. This avoids ' +
540501
'converting them into a regular expression and matching it against ' +
@@ -568,17 +529,14 @@ export const options = {
568529
type: 'array',
569530
},
570531
showConfig: {
571-
default: undefined,
572532
description: 'Print your jest config and then exits.',
573533
type: 'boolean',
574534
},
575535
silent: {
576-
default: undefined,
577536
description: 'Prevent tests from printing messages through the console.',
578537
type: 'boolean',
579538
},
580539
skipFilter: {
581-
default: undefined,
582540
description:
583541
'Disables the filter provided by --filter. Useful for CI jobs, or ' +
584542
'local enforcement when fixing tests.',
@@ -606,7 +564,6 @@ export const options = {
606564
type: 'string', // number
607565
},
608566
testLocationInResults: {
609-
default: false,
610567
description: 'Add `location` information to the test results',
611568
type: 'boolean',
612569
},
@@ -699,7 +656,6 @@ export const options = {
699656
},
700657
updateSnapshot: {
701658
alias: 'u',
702-
default: undefined,
703659
description:
704660
'Use this flag to re-record snapshots. ' +
705661
'Can be used together with a test suite pattern or with ' +
@@ -708,32 +664,27 @@ export const options = {
708664
type: 'boolean',
709665
},
710666
useStderr: {
711-
default: undefined,
712667
description: 'Divert all output to stderr.',
713668
type: 'boolean',
714669
},
715670
verbose: {
716-
default: undefined,
717671
description:
718672
'Display individual test results with the test suite hierarchy.',
719673
type: 'boolean',
720674
},
721675
version: {
722676
alias: 'v',
723-
default: undefined,
724677
description: 'Print the version and exit',
725678
type: 'boolean',
726679
},
727680
watch: {
728-
default: undefined,
729681
description:
730682
'Watch files for changes and rerun tests related to ' +
731683
'changed files. If you want to re-run all tests when a file has ' +
732684
'changed, use the `--watchAll` option.',
733685
type: 'boolean',
734686
},
735687
watchAll: {
736-
default: undefined,
737688
description:
738689
'Watch files for changes and rerun all tests. If you want ' +
739690
'to re-run only the tests related to the changed files, use the ' +
@@ -749,7 +700,6 @@ export const options = {
749700
type: 'array',
750701
},
751702
watchman: {
752-
default: undefined,
753703
description:
754704
'Whether to use watchman for file crawling. Disable using ' +
755705
'--no-watchman.',

0 commit comments

Comments
 (0)