diff --git a/CHANGELOG.md b/CHANGELOG.md index f927a86cc696..d405037f342a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - `[*]` Replace `any`s with `unknown`s ([#9626](https://github.com/facebook/jest/pull/9626)) - `[@jest/transform]` Expose type `CacheKeyOptions` for `getCacheKey` ([#9762](https://github.com/facebook/jest/pull/9762)) +- `[@jest/types]` Correct type `testRegex` for `ProjectConfig` ([#9780](https://github.com/facebook/jest/pull/9780)) ### Performance diff --git a/packages/jest-core/src/SearchSource.ts b/packages/jest-core/src/SearchSource.ts index a2b30f8b2652..7a2c6a863cc6 100644 --- a/packages/jest-core/src/SearchSource.ts +++ b/packages/jest-core/src/SearchSource.ts @@ -40,8 +40,9 @@ export type TestSelectionConfig = { const globsToMatcher = (globs: Array) => (path: Config.Path) => micromatch([replacePathSepForGlob(path)], globs, {dot: true}).length > 0; -const regexToMatcher = (testRegex: Array) => (path: Config.Path) => - testRegex.some(testRegex => new RegExp(testRegex).test(path)); +const regexToMatcher = (testRegex: Config.ProjectConfig['testRegex']) => ( + path: Config.Path, +) => testRegex.some(testRegex => new RegExp(testRegex).test(path)); const toTests = (context: Context, tests: Array) => tests.map(path => ({ diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index 7169f8e13f18..6c5ab99f1a26 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -345,7 +345,7 @@ export type ProjectConfig = { testMatch: Array; testLocationInResults: boolean; testPathIgnorePatterns: Array; - testRegex: Array; + testRegex: Array; testRunner: string; testURL: string; timers: 'real' | 'fake';