Skip to content

Commit c7f9080

Browse files
authored
chore(jest-types): correct type testRegex for ProjectConfig (#9780)
1 parent 222565a commit c7f9080

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
- `[*]` Replace `any`s with `unknown`s ([#9626](https://github.com/facebook/jest/pull/9626))
1515
- `[@jest/transform]` Expose type `CacheKeyOptions` for `getCacheKey` ([#9762](https://github.com/facebook/jest/pull/9762))
16+
- `[@jest/types]` Correct type `testRegex` for `ProjectConfig` ([#9780](https://github.com/facebook/jest/pull/9780))
1617

1718
### Performance
1819

packages/jest-core/src/SearchSource.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ export type TestSelectionConfig = {
4040
const globsToMatcher = (globs: Array<Config.Glob>) => (path: Config.Path) =>
4141
micromatch([replacePathSepForGlob(path)], globs, {dot: true}).length > 0;
4242

43-
const regexToMatcher = (testRegex: Array<string>) => (path: Config.Path) =>
44-
testRegex.some(testRegex => new RegExp(testRegex).test(path));
43+
const regexToMatcher = (testRegex: Config.ProjectConfig['testRegex']) => (
44+
path: Config.Path,
45+
) => testRegex.some(testRegex => new RegExp(testRegex).test(path));
4546

4647
const toTests = (context: Context, tests: Array<Config.Path>) =>
4748
tests.map(path => ({

packages/jest-types/src/Config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export type ProjectConfig = {
345345
testMatch: Array<Glob>;
346346
testLocationInResults: boolean;
347347
testPathIgnorePatterns: Array<string>;
348-
testRegex: Array<string>;
348+
testRegex: Array<string | RegExp>;
349349
testRunner: string;
350350
testURL: string;
351351
timers: 'real' | 'fake';

0 commit comments

Comments
 (0)