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(