Skip to content

Commit

Permalink
Move all default values into jest-config
Browse files Browse the repository at this point in the history
Fixes #8826
  • Loading branch information
ghostd committed Apr 29, 2020
1 parent c5f2fd7 commit 0f16f56
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 53 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,8 @@

### Fixes

- [jest-cli, jest-config, jest-types] Move all default values into `jest-config` ([#9924](https://github.com/facebook/jest/pull/9924))

### Chore & Maintenance

### Performance
Expand Down
2 changes: 0 additions & 2 deletions packages/jest-cli/package.json
Expand Up @@ -19,7 +19,6 @@
"exit": "^0.1.2",
"graceful-fs": "^4.2.4",
"import-local": "^3.0.2",
"is-ci": "^2.0.0",
"jest-config": "^25.5.1",
"jest-util": "^25.5.0",
"jest-validate": "^25.5.0",
Expand All @@ -31,7 +30,6 @@
"@jest/test-utils": "^25.5.0",
"@types/exit": "^0.1.30",
"@types/graceful-fs": "^4.1.3",
"@types/is-ci": "^2.0.0",
"@types/prompts": "^2.0.1",
"@types/yargs": "^15.0.0"
},
Expand Down
52 changes: 1 addition & 51 deletions packages/jest-cli/src/cli/args.ts
Expand Up @@ -7,7 +7,6 @@

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

export function check(argv: Config.Argv): true {
if (argv.runInBand && argv.hasOwnProperty('maxWorkers')) {
Expand Down Expand Up @@ -75,37 +74,33 @@ export const usage =
'Usage: $0 [--config=<pathToConfigFile>] [TestPathPattern]';
export const docs = 'Documentation: https://jestjs.io/';

// The default values are all set in jest-config
export const options = {
all: {
default: undefined,
description:
'The opposite of `onlyChanged`. If `onlyChanged` is set by ' +
'default, running jest with `--all` will force Jest to run all tests ' +
'instead of running only tests related to changed files.',
type: 'boolean',
},
automock: {
default: undefined,
description: 'Automock all files by default.',
type: 'boolean',
},
bail: {
alias: 'b',
default: undefined,
description:
'Exit the test suite immediately after `n` number of failing tests.',
type: 'boolean',
},
browser: {
default: undefined,
description:
'Respect the "browser" field in package.json ' +
'when resolving modules. Some packages export different versions ' +
'based on whether they are operating in node.js or a browser.',
type: 'boolean',
},
cache: {
default: undefined,
description:
'Whether to use the transform cache. Disable the cache ' +
'using --no-cache.',
Expand All @@ -118,7 +113,6 @@ export const options = {
type: 'string',
},
changedFilesWithAncestor: {
default: undefined,
description:
'Runs tests related to the current changes and the changes made in the ' +
'last commit. Behaves similarly to `--onlyChanged`.',
Expand All @@ -133,29 +127,25 @@ export const options = {
type: 'string',
},
ci: {
default: isCI,
description:
'Whether to run Jest in continuous integration (CI) mode. ' +
'This option is on by default in most popular CI environments. It will ' +
'prevent snapshots from being written unless explicitly requested.',
type: 'boolean',
},
clearCache: {
default: undefined,
description:
'Clears the configured Jest cache directory and then exits. ' +
'Default directory can be found by calling jest --showConfig',
type: 'boolean',
},
clearMocks: {
default: undefined,
description:
'Automatically clear mock calls and instances between every ' +
'test. Equivalent to calling jest.clearAllMocks() between each test.',
type: 'boolean',
},
collectCoverage: {
default: undefined,
description: 'Alias for --coverage.',
type: 'boolean',
},
Expand All @@ -171,14 +161,12 @@ export const options = {
type: 'array',
},
color: {
default: undefined,
description:
'Forces test results output color highlighting (even if ' +
'stdout is not a TTY). Set to false if you would like to have no colors.',
type: 'boolean',
},
colors: {
default: undefined,
description: 'Alias for `--color`.',
type: 'boolean',
},
Expand All @@ -192,7 +180,6 @@ export const options = {
type: 'string',
},
coverage: {
default: undefined,
description:
'Indicates that test coverage information should be ' +
'collected and reported in the output.',
Expand Down Expand Up @@ -228,20 +215,17 @@ export const options = {
type: 'string',
},
debug: {
default: undefined,
description: 'Print debugging info about your jest config.',
type: 'boolean',
},
detectLeaks: {
default: false,
description:
'**EXPERIMENTAL**: Detect memory leaks in tests. After executing a ' +
'test, it will try to garbage collect the global object used, and fail ' +
'if it was leaked',
type: 'boolean',
},
detectOpenHandles: {
default: false,
description:
'Print out remaining open handles preventing Jest from exiting at the ' +
'end of a test run. Implies `runInBand`.',
Expand All @@ -255,18 +239,15 @@ export const options = {
type: 'string',
},
errorOnDeprecated: {
default: false,
description: 'Make calling deprecated APIs throw helpful error messages.',
type: 'boolean',
},
expand: {
alias: 'e',
default: undefined,
description: 'Use this flag to show full diffs instead of a patch.',
type: 'boolean',
},
filter: {
default: undefined,
description:
'Path to a module exporting a filtering function. This method receives ' +
'a list of tests which can be manipulated to exclude tests from ' +
Expand All @@ -275,15 +256,13 @@ export const options = {
type: 'string',
},
findRelatedTests: {
default: undefined,
description:
'Find related tests for a list of source files that were ' +
'passed in as arguments. Useful for pre-commit hook integration to run ' +
'the minimal amount of tests necessary.',
type: 'boolean',
},
forceExit: {
default: undefined,
description:
'Force Jest to exit after all tests have completed running. ' +
'This is useful when resources set up by test code cannot be ' +
Expand Down Expand Up @@ -314,44 +293,38 @@ export const options = {
type: 'boolean',
},
json: {
default: undefined,
description:
'Prints the test results in JSON. This mode will send all ' +
'other test output and user messages to stderr.',
type: 'boolean',
},
lastCommit: {
default: undefined,
description:
'Run all tests affected by file changes in the last commit made. ' +
'Behaves similarly to `--onlyChanged`.',
type: 'boolean',
},
listTests: {
default: false,
description:
'Lists all tests Jest will run given the arguments and ' +
'exits. Most useful in a CI system together with `--findRelatedTests` ' +
'to determine the tests Jest will run based on specific files',
type: 'boolean',
},
logHeapUsage: {
default: undefined,
description:
'Logs the heap usage after every test. Useful to debug ' +
'memory leaks. Use together with `--runInBand` and `--expose-gc` in ' +
'node.',
type: 'boolean',
},
mapCoverage: {
default: undefined,
description:
'Maps code coverage reports against original source code ' +
'when transformers supply source maps.\n\nDEPRECATED',
type: 'boolean',
},
maxConcurrency: {
default: 5,
description:
'Specifies the maximum number of tests that are allowed to run' +
'concurrently. This only affects tests using `test.concurrent`.',
Expand Down Expand Up @@ -405,23 +378,19 @@ export const options = {
type: 'array',
},
noStackTrace: {
default: undefined,
description: 'Disables stack trace in test results output',
type: 'boolean',
},
notify: {
default: undefined,
description: 'Activates notifications for test results.',
type: 'boolean',
},
notifyMode: {
default: 'failure-change',
description: 'Specifies when notifications will appear for test results.',
type: 'string',
},
onlyChanged: {
alias: 'o',
default: undefined,
description:
'Attempts to identify which tests to run based on which ' +
"files have changed in the current repository. Only works if you're " +
Expand All @@ -430,7 +399,6 @@ export const options = {
},
onlyFailures: {
alias: 'f',
default: undefined,
description: 'Run tests that failed in the previous execution.',
type: 'boolean',
},
Expand All @@ -441,7 +409,6 @@ export const options = {
type: 'string',
},
passWithNoTests: {
default: false,
description:
'Will not fail if no tests are found (for example while using `--testPathPattern`.)',
type: 'boolean',
Expand All @@ -451,7 +418,6 @@ export const options = {
type: 'string',
},
prettierPath: {
default: undefined,
description: 'The path to the "prettier" module used for inline snapshots.',
type: 'string',
},
Expand All @@ -468,14 +434,12 @@ export const options = {
type: 'array',
},
resetMocks: {
default: undefined,
description:
'Automatically reset mock state between every test. ' +
'Equivalent to calling jest.resetAllMocks() between each test.',
type: 'boolean',
},
resetModules: {
default: undefined,
description:
'If enabled, the module registry for every test file will ' +
'be reset before running each individual test.',
Expand All @@ -486,7 +450,6 @@ export const options = {
type: 'string',
},
restoreMocks: {
default: undefined,
description:
'Automatically restore mock state and implementation between every test. ' +
'Equivalent to calling jest.restoreAllMocks() between each test.',
Expand All @@ -507,7 +470,6 @@ export const options = {
},
runInBand: {
alias: 'i',
default: undefined,
description:
'Run all tests serially in the current process (rather than ' +
'creating a worker pool of child processes that run tests). This ' +
Expand All @@ -516,7 +478,6 @@ export const options = {
type: 'boolean',
},
runTestsByPath: {
default: false,
description:
'Used when provided patterns are exact file paths. This avoids ' +
'converting them into a regular expression and matching it against ' +
Expand All @@ -543,17 +504,14 @@ export const options = {
type: 'array',
},
showConfig: {
default: undefined,
description: 'Print your jest config and then exits.',
type: 'boolean',
},
silent: {
default: undefined,
description: 'Prevent tests from printing messages through the console.',
type: 'boolean',
},
skipFilter: {
default: undefined,
description:
'Disables the filter provided by --filter. Useful for CI jobs, or ' +
'local enforcement when fixing tests.',
Expand Down Expand Up @@ -581,7 +539,6 @@ export const options = {
type: 'string', // number
},
testLocationInResults: {
default: false,
description: 'Add `location` information to the test results',
type: 'boolean',
},
Expand Down Expand Up @@ -674,7 +631,6 @@ export const options = {
},
updateSnapshot: {
alias: 'u',
default: undefined,
description:
'Use this flag to re-record snapshots. ' +
'Can be used together with a test suite pattern or with ' +
Expand All @@ -683,32 +639,27 @@ export const options = {
type: 'boolean',
},
useStderr: {
default: undefined,
description: 'Divert all output to stderr.',
type: 'boolean',
},
verbose: {
default: undefined,
description:
'Display individual test results with the test suite hierarchy.',
type: 'boolean',
},
version: {
alias: 'v',
default: undefined,
description: 'Print the version and exit',
type: 'boolean',
},
watch: {
default: undefined,
description:
'Watch files for changes and rerun tests related to ' +
'changed files. If you want to re-run all tests when a file has ' +
'changed, use the `--watchAll` option.',
type: 'boolean',
},
watchAll: {
default: undefined,
description:
'Watch files for changes and rerun all tests. If you want ' +
'to re-run only the tests related to the changed files, use the ' +
Expand All @@ -724,7 +675,6 @@ export const options = {
type: 'array',
},
watchman: {
default: undefined,
description:
'Whether to use watchman for file crawling. Disable using ' +
'--no-watchman.',
Expand Down

0 comments on commit 0f16f56

Please sign in to comment.