Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jest-config): allow coverageDirectory and collectCoverageFrom in project config #14180

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,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