Skip to content

Commit bc05989

Browse files
authored
chore(jest-haste-map): remove support for ignorePattern as function (#10348)
1 parent 831139b commit bc05989

3 files changed

Lines changed: 13 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
- `[jest-console]` [**BREAKING**] Move `root` into `config` and take `GlobalConfig` as mandatory parameter for `getConsoleOutput` ([#10126](https://github.com/facebook/jest/pull/10126))
4848
- `[jest-fake-timers]` Clarify global behavior of `jest.useFakeTimers` and `jest.useRealTimers` ([#10867](https://github.com/facebook/jest/pull/10867))
4949
- `[jest-haste-map]` [**BREAKING**] Migrate to ESM ([#10875](https://github.com/facebook/jest/pull/10875))
50+
- `[jest-haste-map]` [**BREAKING**] Remove support for deprecated option `ignorePattern` as function ([#10348](https://github.com/facebook/jest/pull/10348))
5051
- `[jest-jasmine2]` [**BREAKING**] Migrate to ESM ([#10906](https://github.com/facebook/jest/pull/10906))
5152
- `[jest-repl, jest-runtime]` [**BREAKING**] Move the `jest-runtime` CLI into `jest-repl` ([#10016](https://github.com/facebook/jest/pull/10016))
5253
- `[jest-resolve]` [**BREAKING**] Migrate to ESM ([#10688](https://github.com/facebook/jest/pull/10688))

packages/jest-haste-map/src/__tests__/index.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,19 +326,19 @@ describe('HasteMap', () => {
326326
});
327327
});
328328

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

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

344344
it('builds a haste map on a fresh cache', () => {

packages/jest-haste-map/src/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,8 @@ export default class HasteMap extends EventEmitter {
254254
options.ignorePattern.flags,
255255
);
256256
} else {
257-
const ignorePattern = options.ignorePattern;
258-
const vcsIgnoreRegExp = new RegExp(VCS_DIRECTORIES);
259-
this._options.ignorePattern = (filePath: string) =>
260-
vcsIgnoreRegExp.test(filePath) || ignorePattern(filePath);
261-
262-
this._console.warn(
263-
'jest-haste-map: the `ignorePattern` options as a function is being ' +
264-
'deprecated. Provide a RegExp instead. See https://github.com/facebook/jest/pull/4063.',
257+
throw new Error(
258+
'jest-haste-map: the `ignorePattern` option must be a RegExp',
265259
);
266260
}
267261
} else {

0 commit comments

Comments
 (0)