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

fix(jest-haste-map): don't throw on missing mapper in Node crawler #8558

Merged
merged 3 commits into from
Jun 13, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- `[babel-plugin-jest-hoist]` Expand list of whitelisted globals in global mocks ([#8429](https://github.com/facebook/jest/pull/8429)
- `[jest-core]` Make watch plugin initialization errors look nice ([#8422](https://github.com/facebook/jest/pull/8422))
- `[jest-snapshot]` Prevent inline snapshots from drifting when inline snapshots are updated ([#8492](https://github.com/facebook/jest/pull/8492))
- `[jest-haste-map]` Don't pass mapper to Node crawler snapshots are updated ([#8558](https://github.com/facebook/jest/pull/8558))

### Chore & Maintenance

Expand Down
4 changes: 4 additions & 0 deletions packages/jest-haste-map/src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,9 @@ describe('HasteMap', () => {
node.mockImplementation(options => {
const {data} = options;

// `mapper` is not supported in Node crawl
expect(options.mapper).toBeUndefined();

// The node crawler returns "null" for the SHA-1.
data.files = createMap({
'fruits/Banana.js': ['Banana', 32, 42, 0, 'Strawberry', null],
Expand All @@ -426,6 +429,7 @@ describe('HasteMap', () => {
const hasteMap = new HasteMap({
...defaultConfig,
computeSha1: true,
mapper: file => [file],
maxWorkers: 1,
useWatchman,
});
Expand Down
6 changes: 3 additions & 3 deletions packages/jest-haste-map/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -741,15 +741,15 @@ class HasteMap extends EventEmitter {
private _crawl(hasteMap: InternalHasteMap) {
const options = this._options;
const ignore = this._ignore.bind(this);
const crawl =
canUseWatchman && this._options.useWatchman ? watchmanCrawl : nodeCrawl;
const useWatchman = canUseWatchman && this._options.useWatchman;
const crawl = useWatchman ? watchmanCrawl : nodeCrawl;
const crawlerOptions: CrawlerOptions = {
computeSha1: options.computeSha1,
data: hasteMap,
extensions: options.extensions,
forceNodeFilesystemAPI: options.forceNodeFilesystemAPI,
ignore,
mapper: options.mapper,
mapper: useWatchman ? options.mapper : undefined,
thymikee marked this conversation as resolved.
Show resolved Hide resolved
rootDir: options.rootDir,
roots: options.roots,
};
Expand Down