Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(jest-haste-map): remove support for ignorePattern as function #10348

Merged
merged 8 commits into from Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -45,6 +45,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