diff --git a/packages/jest-haste-map/src/__tests__/index.test.js b/packages/jest-haste-map/src/__tests__/index.test.js index 7c61b632bd1c..32f416720fa1 100644 --- a/packages/jest-haste-map/src/__tests__/index.test.js +++ b/packages/jest-haste-map/src/__tests__/index.test.js @@ -100,6 +100,7 @@ let mockClocks; let mockEmitters; let object; let workerFarmMock; +let getCacheFilePath; describe('HasteMap', () => { skipOnWindows.suite(); @@ -152,6 +153,7 @@ describe('HasteMap', () => { HasteMap = require('../'); H = HasteMap.H; + getCacheFilePath = HasteMap.getCacheFilePath; HasteMap.getCacheFilePath = jest.fn(() => cacheFilePath); defaultConfig = { @@ -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(); @@ -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); }); }); }); diff --git a/packages/jest-haste-map/src/index.js b/packages/jest-haste-map/src/index.js index 4dc3ae4d078a..b38df77b2ce7 100644 --- a/packages/jest-haste-map/src/index.js +++ b/packages/jest-haste-map/src/index.js @@ -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}`, @@ -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;