From 742e5765ca88799e6ae5c327a7671ea49ba0442e Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Thu, 25 May 2017 05:01:34 -0700 Subject: [PATCH] packager: upgrade jest-haste-map version Summary: This allows us to get the new fix for recovery on duplicate modules. Reviewed By: cpojer Differential Revision: D5128975 fbshipit-source-id: 5a2b60430bbca1806a97798c482af8522366e071 --- package.json | 2 +- packager/package.json | 2 +- .../__tests__/DependencyGraph-test.js | 18 ++++------ .../DependencyGraph-test.js.snap | 36 +++++++++++++++++++ packager/src/node-haste/index.js | 2 +- 5 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 packager/src/node-haste/__tests__/__snapshots__/DependencyGraph-test.js.snap diff --git a/package.json b/package.json index 7968d4021504e6..66995eae0bab8b 100644 --- a/package.json +++ b/package.json @@ -170,7 +170,7 @@ "immutable": "~3.7.6", "imurmurhash": "^0.1.4", "inquirer": "^0.12.0", - "jest-haste-map": "19.0.0", + "jest-haste-map": "^20.0.4", "joi": "^6.6.1", "json-stable-stringify": "^1.0.1", "json5": "^0.4.0", diff --git a/packager/package.json b/packager/package.json index e6386cc9165199..570a282807c7a1 100644 --- a/packager/package.json +++ b/packager/package.json @@ -25,7 +25,7 @@ "graceful-fs": "^4.1.3", "image-size": "^0.3.5", "imurmurhash": "^0.1.4", - "jest-haste-map": "18.0.0", + "jest-haste-map": "^20.0.4", "joi": "^6.6.1", "json-stable-stringify": "^1.0.1", "json5": "^0.4.0", diff --git a/packager/src/node-haste/__tests__/DependencyGraph-test.js b/packager/src/node-haste/__tests__/DependencyGraph-test.js index f55ee0a9137123..91bf72125dc656 100644 --- a/packager/src/node-haste/__tests__/DependencyGraph-test.js +++ b/packager/src/node-haste/__tests__/DependencyGraph-test.js @@ -5182,7 +5182,7 @@ describe('DependencyGraph', function() { }); }); - it('should recover from multiple modules with the same name (but this is broken right now)', async () => { + it('should recover from multiple modules with the same name', async () => { const root = '/root'; console.warn = jest.fn(); const filesystem = setMockFileSystem({ @@ -5231,17 +5231,11 @@ describe('DependencyGraph', function() { await triggerAndProcessWatchEvent(dgraph, 'change', root + '/b.js'); } - // This verifies that it is broken right now. Instead of throwing it should - // return correct results. Once this is fixed in `jest-haste`, remove - // the whole try catch and verify results are matching a snapshot. - try { - await getOrderedDependenciesAsJSON(dgraph, root + '/index.js'); - throw new Error('expected `getOrderedDependenciesAsJSON` to fail'); - } catch (error) { - if (error.type !== 'UnableToResolveError') { - throw error; - } - } + const deps = await getOrderedDependenciesAsJSON( + dgraph, + root + '/index.js', + ); + expect(deps).toMatchSnapshot(); }); }); diff --git a/packager/src/node-haste/__tests__/__snapshots__/DependencyGraph-test.js.snap b/packager/src/node-haste/__tests__/__snapshots__/DependencyGraph-test.js.snap new file mode 100644 index 00000000000000..dbd9ae1f45e0cf --- /dev/null +++ b/packager/src/node-haste/__tests__/__snapshots__/DependencyGraph-test.js.snap @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DependencyGraph file watch updating should recover from multiple modules with the same name 1`] = ` +Array [ + Object { + "dependencies": Array [ + "a", + "b", + ], + "id": "index", + "isAsset": false, + "isJSON": false, + "isPolyfill": false, + "path": "/root/index.js", + "resolution": undefined, + }, + Object { + "dependencies": Array [], + "id": "a", + "isAsset": false, + "isJSON": false, + "isPolyfill": false, + "path": "/root/a.js", + "resolution": undefined, + }, + Object { + "dependencies": Array [], + "id": "b", + "isAsset": false, + "isJSON": false, + "isPolyfill": false, + "path": "/root/b.js", + "resolution": undefined, + }, +] +`; diff --git a/packager/src/node-haste/index.js b/packager/src/node-haste/index.js index 0bf17a9115e192..328abfe3d596a0 100644 --- a/packager/src/node-haste/index.js +++ b/packager/src/node-haste/index.js @@ -103,7 +103,7 @@ class DependencyGraph extends EventEmitter { return new JestHasteMap({ extensions: opts.extensions.concat(opts.assetExts), forceNodeFilesystemAPI: opts.forceNodeFilesystemAPI, - ignorePattern: {test: opts.ignoreFilePath}, + ignorePattern: opts.ignoreFilePath, maxWorkers: opts.maxWorkerCount, mocksPattern: '', name: 'react-native-packager-' + JEST_HASTE_MAP_CACHE_BREAKER,