Skip to content

Commit

Permalink
jest-haste-map: add test case for broken handling of ignore pattern (j…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanlauliac authored and cpojer committed Jul 17, 2017
1 parent 60689e7 commit 17bde04
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/jest-haste-map/src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 17bde04

Please sign in to comment.