Skip to content

Commit

Permalink
fix: coverage config moved to project (jestjs#9628)
Browse files Browse the repository at this point in the history
Moved the following config props from globalConfig to projectConfig:
collectCoverageFrom, collectCoverageOnlyFrom, coverageThreshold

You can now specify those properties per project.

As a side effect, they were removed from the whitelist of watch-able properties.
  • Loading branch information
Roy Razon committed Apr 12, 2020
1 parent c830517 commit 69a45d6
Show file tree
Hide file tree
Showing 22 changed files with 220 additions and 150 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Features

- `[jest-config]` [**BREAKING**] Move coverage options to project config ([#9633](https://github.com/facebook/jest/pull/9633))
- `[jest-console]` Add code frame to `console.error` and `console.warn` ([#9741](https://github.com/facebook/jest/pull/9741))
- `[@jest/globals]` New package so Jest's globals can be explicitly imported ([#9801](https://github.com/facebook/jest/pull/9801))

Expand Down
6 changes: 3 additions & 3 deletions TestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ const DEFAULT_GLOBAL_CONFIG: Config.GlobalConfig = {
changedFilesWithAncestor: false,
changedSince: '',
collectCoverage: false,
collectCoverageFrom: [],
collectCoverageOnlyFrom: null,
coverageDirectory: 'coverage',
coverageProvider: 'babel',
coverageReporters: [],
coverageThreshold: {global: {}},
detectLeaks: false,
detectOpenHandles: false,
enabledTestsMap: null,
Expand Down Expand Up @@ -71,7 +68,10 @@ const DEFAULT_PROJECT_CONFIG: Config.ProjectConfig = {
cache: false,
cacheDirectory: '/test_cache_dir/',
clearMocks: false,
collectCoverageFrom: [],
collectCoverageOnlyFrom: null,
coveragePathIgnorePatterns: [],
coverageThreshold: {global: {}},
cwd: '/test_root_dir/',
detectLeaks: false,
detectOpenHandles: false,
Expand Down
2 changes: 0 additions & 2 deletions docs/WatchPlugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ For stability and safety reasons, only part of the global configuration keys can
- [`bail`](configuration.html#bail-number--boolean)
- [`changedSince`](cli.html#--changedsince)
- [`collectCoverage`](configuration.html#collectcoverage-boolean)
- [`collectCoverageFrom`](configuration.html#collectcoveragefrom-array)
- [`collectCoverageOnlyFrom`](configuration.html#collectcoverageonlyfrom-array)
- [`coverageDirectory`](configuration.html#coveragedirectory-string)
- [`coverageReporters`](configuration.html#coveragereporters-arraystring)
- [`notify`](configuration.html#notify-boolean)
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/__snapshots__/showConfig.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`--showConfig outputs config info and exits 1`] = `
"cache": false,
"cacheDirectory": "/tmp/jest",
"clearMocks": false,
"collectCoverageFrom": [],
"coveragePathIgnorePatterns": [
"/node_modules/"
],
Expand Down Expand Up @@ -82,7 +83,6 @@ exports[`--showConfig outputs config info and exits 1`] = `
"bail": 0,
"changedFilesWithAncestor": false,
"collectCoverage": false,
"collectCoverageFrom": [],
"coverageDirectory": "<<REPLACED_ROOT_DIR>>/coverage",
"coverageProvider": "babel",
"coverageReporters": [
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,9 @@ const groupOptions = (
changedFilesWithAncestor: options.changedFilesWithAncestor,
changedSince: options.changedSince,
collectCoverage: options.collectCoverage,
collectCoverageFrom: options.collectCoverageFrom,
collectCoverageOnlyFrom: options.collectCoverageOnlyFrom,
coverageDirectory: options.coverageDirectory,
coverageProvider: options.coverageProvider,
coverageReporters: options.coverageReporters,
coverageThreshold: options.coverageThreshold,
detectLeaks: options.detectLeaks,
detectOpenHandles: options.detectOpenHandles,
enabledTestsMap: options.enabledTestsMap,
Expand Down Expand Up @@ -167,7 +164,10 @@ const groupOptions = (
cache: options.cache,
cacheDirectory: options.cacheDirectory,
clearMocks: options.clearMocks,
collectCoverageFrom: options.collectCoverageFrom,
collectCoverageOnlyFrom: options.collectCoverageOnlyFrom,
coveragePathIgnorePatterns: options.coveragePathIgnorePatterns,
coverageThreshold: options.coverageThreshold,
cwd: options.cwd,
dependencyExtractor: options.dependencyExtractor,
detectLeaks: options.detectLeaks,
Expand Down
3 changes: 0 additions & 3 deletions packages/jest-core/src/__tests__/watch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,8 @@ describe('Watch mode flows', () => {
${'✖︎'} | ${'changedFilesWithAncestor'}
${'✔︎'} | ${'changedSince'}
${'✔︎'} | ${'collectCoverage'}
${'✔︎'} | ${'collectCoverageFrom'}
${'✔︎'} | ${'collectCoverageOnlyFrom'}
${'✔︎'} | ${'coverageDirectory'}
${'✔︎'} | ${'coverageReporters'}
${'✖︎'} | ${'coverageThreshold'}
${'✖︎'} | ${'detectLeaks'}
${'✖︎'} | ${'detectOpenHandles'}
${'✖︎'} | ${'enabledTestsMap'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ exports[`prints the config object 1`] = `
"cache": false,
"cacheDirectory": "/test_cache_dir/",
"clearMocks": false,
"collectCoverageFrom": [],
"collectCoverageOnlyFrom": null,
"coveragePathIgnorePatterns": [],
"coverageThreshold": {
"global": {}
},
"cwd": "/test_root_dir/",
"detectLeaks": false,
"detectOpenHandles": false,
Expand Down Expand Up @@ -68,14 +73,9 @@ exports[`prints the config object 1`] = `
"changedFilesWithAncestor": false,
"changedSince": "",
"collectCoverage": false,
"collectCoverageFrom": [],
"collectCoverageOnlyFrom": null,
"coverageDirectory": "coverage",
"coverageProvider": "babel",
"coverageReporters": [],
"coverageThreshold": {
"global": {}
},
"detectLeaks": false,
"detectOpenHandles": false,
"enabledTestsMap": null,
Expand Down
8 changes: 0 additions & 8 deletions packages/jest-core/src/lib/update_global_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ export default (
newConfig.collectCoverage = options.collectCoverage || false;
}

if (options.collectCoverageFrom !== undefined) {
newConfig.collectCoverageFrom = options.collectCoverageFrom;
}

if (options.collectCoverageOnlyFrom !== undefined) {
newConfig.collectCoverageOnlyFrom = options.collectCoverageOnlyFrom;
}

if (options.coverageDirectory !== undefined) {
newConfig.coverageDirectory = options.coverageDirectory;
}
Expand Down
4 changes: 0 additions & 4 deletions packages/jest-core/src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ export default function watch(
bail,
changedSince,
collectCoverage,
collectCoverageFrom,
collectCoverageOnlyFrom,
coverageDirectory,
coverageReporters,
mode,
Expand All @@ -122,8 +120,6 @@ export default function watch(
bail,
changedSince,
collectCoverage,
collectCoverageFrom,
collectCoverageOnlyFrom,
coverageDirectory,
coverageReporters,
mode,
Expand Down
Loading

0 comments on commit 69a45d6

Please sign in to comment.