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: add test case for broken handling of ignore pattern #4047

Merged
merged 1 commit into from
Jul 17, 2017
Merged
Changes from all commits
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
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