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

jest-haste-map: deprecate functional ignorePattern and use it in cache key #4063

Merged
merged 2 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/jest-haste-map/src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ let mockClocks;
let mockEmitters;
let object;
let workerFarmMock;
let getCacheFilePath;

describe('HasteMap', () => {
skipOnWindows.suite();
Expand Down Expand Up @@ -152,6 +153,7 @@ describe('HasteMap', () => {
HasteMap = require('../');
H = HasteMap.H;

getCacheFilePath = HasteMap.getCacheFilePath;
HasteMap.getCacheFilePath = jest.fn(() => cacheFilePath);

defaultConfig = {
Expand Down Expand Up @@ -547,7 +549,8 @@ describe('HasteMap', () => {
});
});

it('discards the cache when configuration changes (broken)', () => {
it('discards the cache when configuration changes', () => {
HasteMap.getCacheFilePath = getCacheFilePath;
return new HasteMap(defaultConfig).build().then(() => {
fs.readFileSync.mockClear();

Expand All @@ -564,9 +567,7 @@ describe('HasteMap', () => {
ignorePattern: /kiwi|pear/,
});
return new HasteMap(config).build().then(({moduleMap}) => {
// `getModule` should actually return `null` here, because Pear
// should get ignored by the pattern.
expect(typeof moduleMap.getModule('Pear')).toBe('string');
expect(moduleMap.getModule('Pear')).toBe(null);
});
});
});
Expand Down
7 changes: 7 additions & 0 deletions packages/jest-haste-map/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ class HasteMap extends EventEmitter {
watch: !!options.watch,
};
this._console = options.console || global.console;
if (!(options.ignorePattern instanceof RegExp)) {
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.'
);
}
this._cachePath = HasteMap.getCacheFilePath(
this._options.cacheDirectory,
`haste-map-${this._options.name}`,
Expand All @@ -232,6 +238,7 @@ class HasteMap extends EventEmitter {
this._options.extensions.join(':'),
this._options.platforms.join(':'),
options.mocksPattern || '',
options.ignorePattern.toString(),
);
this._whitelist = getWhiteList(options.providesModuleNodeModules);
this._buildPromise = null;
Expand Down