From d2d7a2330c247c9a72bf910bdc5266bbed401e2d Mon Sep 17 00:00:00 2001 From: OJ Kwon Date: Fri, 9 Jun 2017 02:09:58 -0700 Subject: [PATCH] Completes nodeCrawl with empty roots (#3776) --- .../src/crawlers/__tests__/node-test.js | 17 +++++++++++++++++ packages/jest-haste-map/src/crawlers/node.js | 6 +++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/jest-haste-map/src/crawlers/__tests__/node-test.js b/packages/jest-haste-map/src/crawlers/__tests__/node-test.js index e488f9d70215..edf90acbb10a 100644 --- a/packages/jest-haste-map/src/crawlers/__tests__/node-test.js +++ b/packages/jest-haste-map/src/crawlers/__tests__/node-test.js @@ -198,4 +198,21 @@ describe('node crawler', () => { }); }); }); + + it('completes with emtpy roots', () => { + process.platform = 'win32'; + + nodeCrawl = require('../node'); + + const files = Object.create(null); + return nodeCrawl({ + data: {files}, + extensions: ['js'], + forceNodeFilesystemAPI: true, + ignore: pearMatcher, + roots: [], + }).then(data => { + expect(data.files).toEqual({}); + }); + }); }); diff --git a/packages/jest-haste-map/src/crawlers/node.js b/packages/jest-haste-map/src/crawlers/node.js index 3b35c6cd40b8..a121ba236080 100644 --- a/packages/jest-haste-map/src/crawlers/node.js +++ b/packages/jest-haste-map/src/crawlers/node.js @@ -65,7 +65,11 @@ function find( }); } - roots.forEach(search); + if (roots.length > 0) { + roots.forEach(search); + } else { + callback(result); + } } function findNative(