From 7a5591b3ff7ef7c788cf77fb01f9082e29e53682 Mon Sep 17 00:00:00 2001 From: Ahn Date: Tue, 7 Apr 2020 21:15:35 +0200 Subject: [PATCH] chore(jest-types): correct type for testRegex for ProjectConfig --- CHANGELOG.md | 1 + packages/jest-core/src/SearchSource.ts | 5 +++-- packages/jest-types/src/Config.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52907ddec033..abcc005221e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,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';