diff --git a/packages/jest-haste-map/src/__tests__/index.test.js b/packages/jest-haste-map/src/__tests__/index.test.js index 455671780cdb..10ef316f7c6d 100644 --- a/packages/jest-haste-map/src/__tests__/index.test.js +++ b/packages/jest-haste-map/src/__tests__/index.test.js @@ -548,6 +548,36 @@ describe('HasteMap', () => { }); }); + it('discards the cache when configuration changes (broken)', () => { + return new HasteMap(defaultConfig) + .build() + .then(() => { + fs.readFileSync.mockClear(); + + // Explicitly mock that no files have changed. + mockChangedFiles = Object.create(null); + + // Watchman would give us different clocks. + mockClocks = object({ + '/fruits': 'c:fake-clock:3', + '/vegetables': 'c:fake-clock:4', + }); + + const config = Object.assign( + {}, + defaultConfig, + {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'); + }); + }); + }); + it('ignores files that do not exist', () => { const watchman = require('../crawlers/watchman'); const mockImpl = watchman.getMockImplementation();