From 39fa586665eba09e1e5be72282cca95ab9c9e318 Mon Sep 17 00:00:00 2001 From: Caleb Ukle Date: Thu, 1 Jun 2023 16:05:08 -0500 Subject: [PATCH] fix(jest-config): allow coverageDirectory and collectCoverageFrom in project config --- packages/jest-config/src/ValidConfig.ts | 2 ++ packages/jest-config/src/index.ts | 2 ++ packages/jest-types/src/Config.ts | 2 ++ packages/test-utils/src/config.ts | 2 ++ 4 files changed, 8 insertions(+) diff --git a/packages/jest-config/src/ValidConfig.ts b/packages/jest-config/src/ValidConfig.ts index f6de3eac3338..6acf984b41dd 100644 --- a/packages/jest-config/src/ValidConfig.ts +++ b/packages/jest-config/src/ValidConfig.ts @@ -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: '/dependencyExtractor.js', detectLeaks: false, diff --git a/packages/jest-config/src/index.ts b/packages/jest-config/src/index.ts index f68c5f19b0c0..ecdab9a89591 100644 --- a/packages/jest-config/src/index.ts +++ b/packages/jest-config/src/index.ts @@ -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, diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index 54240a747037..024896fb8a0b 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -435,6 +435,8 @@ export type ProjectConfig = { cache: boolean; cacheDirectory: string; clearMocks: boolean; + collectCoverageFrom: Array; + coverageDirectory: string; coveragePathIgnorePatterns: Array; cwd: string; dependencyExtractor?: string; diff --git a/packages/test-utils/src/config.ts b/packages/test-utils/src/config.ts index 0ef998c88636..61b6ded274b2 100644 --- a/packages/test-utils/src/config.ts +++ b/packages/test-utils/src/config.ts @@ -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,