Skip to content

Commit

Permalink
chore(jest-haste-map): remove support for ignorePattern as function (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
komtaki committed Dec 5, 2020
1 parent 831139b commit bc05989
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -47,6 +47,7 @@
- `[jest-console]` [**BREAKING**] Move `root` into `config` and take `GlobalConfig` as mandatory parameter for `getConsoleOutput` ([#10126](https://github.com/facebook/jest/pull/10126))
- `[jest-fake-timers]` Clarify global behavior of `jest.useFakeTimers` and `jest.useRealTimers` ([#10867](https://github.com/facebook/jest/pull/10867))
- `[jest-haste-map]` [**BREAKING**] Migrate to ESM ([#10875](https://github.com/facebook/jest/pull/10875))
- `[jest-haste-map]` [**BREAKING**] Remove support for deprecated option `ignorePattern` as function ([#10348](https://github.com/facebook/jest/pull/10348))
- `[jest-jasmine2]` [**BREAKING**] Migrate to ESM ([#10906](https://github.com/facebook/jest/pull/10906))
- `[jest-repl, jest-runtime]` [**BREAKING**] Move the `jest-runtime` CLI into `jest-repl` ([#10016](https://github.com/facebook/jest/pull/10016))
- `[jest-resolve]` [**BREAKING**] Migrate to ESM ([#10688](https://github.com/facebook/jest/pull/10688))
Expand Down
20 changes: 10 additions & 10 deletions packages/jest-haste-map/src/__tests__/index.test.js
Expand Up @@ -326,19 +326,19 @@ describe('HasteMap', () => {
});
});

it('ignores vcs directories with ignore pattern function', () => {
const config = {...defaultConfig, ignorePattern: f => /Kiwi/.test(f)};
mockFs[path.join('/', 'project', 'fruits', 'Kiwi.js')] = `
it('warn on ignore pattern except for regex', () => {
const config = {ignorePattern: 'Kiwi', ...defaultConfig};
mockFs['/project/fruits/Kiwi.js'] = `
// Kiwi!
`;

mockFs[path.join('/', 'project', 'fruits', '.git', 'fruit-history.js')] = `
// test
`;
return new HasteMap(config).build().then(({hasteFS}) => {
expect(hasteFS.matchFiles(/Kiwi/)).toEqual([]);
expect(hasteFS.matchFiles('.git')).toEqual([]);
});
try {
new HasteMap(config).build();
} catch (err) {
expect(err.message).toBe(
'jest-haste-map: the `ignorePattern` option must be a RegExp',
);
}
});

it('builds a haste map on a fresh cache', () => {
Expand Down
10 changes: 2 additions & 8 deletions packages/jest-haste-map/src/index.ts
Expand Up @@ -254,14 +254,8 @@ export default class HasteMap extends EventEmitter {
options.ignorePattern.flags,
);
} else {
const ignorePattern = options.ignorePattern;
const vcsIgnoreRegExp = new RegExp(VCS_DIRECTORIES);
this._options.ignorePattern = (filePath: string) =>
vcsIgnoreRegExp.test(filePath) || ignorePattern(filePath);

this._console.warn(
'jest-haste-map: the `ignorePattern` options as a function is being ' +
'deprecated. Provide a RegExp instead. See https://github.com/facebook/jest/pull/4063.',
throw new Error(
'jest-haste-map: the `ignorePattern` option must be a RegExp',
);
}
} else {
Expand Down

0 comments on commit bc05989

Please sign in to comment.