Skip to content

Commit

Permalink
fix(jest-config): allow coverageDirectory and collectCoverageFrom in …
Browse files Browse the repository at this point in the history
…project config (#14180)

Co-authored-by: Simen Bekkhus <sbekkhus91@gmail.com>
  • Loading branch information
barbados-clemens and SimenB committed Jun 21, 2023
1 parent ca0557b commit 9653d88
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@
### Fixes

- `[jest-config]` Handle frozen config object ([#14054](https://github.com/facebook/jest/pull/14054))
- `[jest-config]` Allow `coverageDirectory` and `collectCoverageFrom` in project config ([#14180](https://github.com/jestjs/jest/pull/14180))
- `[jest-core]` Always use workers in watch mode to avoid crashes ([#14059](https://github.com/facebook/jest/pull/14059)).
- `[jest-environment-jsdom, jest-environment-node]` Fix assignment of `customExportConditions` via `testEnvironmentOptions` when custom env subclass defines a default value ([#13989](https://github.com/facebook/jest/pull/13989))
- `[jest-matcher-utils]` Fix copying value of inherited getters ([#14007](https://github.com/facebook/jest/pull/14007))
Expand Down
2 changes: 2 additions & 0 deletions e2e/__tests__/__snapshots__/showConfig.test.ts.snap
Expand Up @@ -8,6 +8,8 @@ exports[`--showConfig outputs config info and exits 1`] = `
"cache": false,
"cacheDirectory": "/tmp/jest",
"clearMocks": false,
"collectCoverageFrom": [],
"coverageDirectory": "<<REPLACED_ROOT_DIR>>/coverage",
"coveragePathIgnorePatterns": [
"/node_modules/"
],
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-config/src/ValidConfig.ts
Expand Up @@ -196,6 +196,8 @@ export const initialProjectOptions: Config.InitialProjectOptions = {
cache: true,
cacheDirectory: '/tmp/user/jest',
clearMocks: false,
collectCoverageFrom: ['src', '!public'],
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: [NODE_MODULES_REGEXP],
dependencyExtractor: '<rootDir>/dependencyExtractor.js',
detectLeaks: false,
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-config/src/index.ts
Expand Up @@ -149,6 +149,8 @@ const groupOptions = (
cache: options.cache,
cacheDirectory: options.cacheDirectory,
clearMocks: options.clearMocks,
collectCoverageFrom: options.collectCoverageFrom,
coverageDirectory: options.coverageDirectory,
coveragePathIgnorePatterns: options.coveragePathIgnorePatterns,
cwd: options.cwd,
dependencyExtractor: options.dependencyExtractor,
Expand Down
Expand Up @@ -7,6 +7,11 @@ exports[`prints the config object 1`] = `
"cache": false,
"cacheDirectory": "/test_cache_dir/",
"clearMocks": false,
"collectCoverageFrom": [
"src",
"!public"
],
"coverageDirectory": "coverage",
"coveragePathIgnorePatterns": [],
"cwd": "/test_root_dir/",
"detectLeaks": false,
Expand Down

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/jest-types/src/Config.ts
Expand Up @@ -435,6 +435,8 @@ export type ProjectConfig = {
cache: boolean;
cacheDirectory: string;
clearMocks: boolean;
collectCoverageFrom: Array<string>;
coverageDirectory: string;
coveragePathIgnorePatterns: Array<string>;
cwd: string;
dependencyExtractor?: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/test-utils/src/config.ts
Expand Up @@ -72,6 +72,8 @@ const DEFAULT_PROJECT_CONFIG: Config.ProjectConfig = {
cache: false,
cacheDirectory: '/test_cache_dir/',
clearMocks: false,
collectCoverageFrom: ['src', '!public'],
coverageDirectory: 'coverage',
coveragePathIgnorePatterns: [],
cwd: '/test_root_dir/',
detectLeaks: false,
Expand Down

0 comments on commit 9653d88

Please sign in to comment.