Skip to content

Commit

Permalink
chore(jest-types): correct type testRegex for ProjectConfig (#9780)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl authored Apr 8, 2020
1 parent 222565a commit c7f9080
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions packages/jest-core/src/SearchSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export type TestSelectionConfig = {
const globsToMatcher = (globs: Array<Config.Glob>) => (path: Config.Path) =>
micromatch([replacePathSepForGlob(path)], globs, {dot: true}).length > 0;

const regexToMatcher = (testRegex: Array<string>) => (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<Config.Path>) =>
tests.map(path => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-types/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ export type ProjectConfig = {
testMatch: Array<Glob>;
testLocationInResults: boolean;
testPathIgnorePatterns: Array<string>;
testRegex: Array<string>;
testRegex: Array<string | RegExp>;
testRunner: string;
testURL: string;
timers: 'real' | 'fake';
Expand Down

0 comments on commit c7f9080

Please sign in to comment.