From ece4a18d7ceb36727a285df3934e49d01fb5fef1 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Tue, 15 Nov 2016 03:34:45 -0800 Subject: [PATCH] packager: DependencyGraph-test: require extractDependencies only once Reviewed By: davidaurelio Differential Revision: D4182071 fbshipit-source-id: 622cb3e011b67c2a7df0c6308fbcb7a9ea1ebb96 --- .../src/node-haste/__tests__/DependencyGraph-test.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/react-packager/src/node-haste/__tests__/DependencyGraph-test.js b/react-packager/src/node-haste/__tests__/DependencyGraph-test.js index 655b14b5..e7ba87ab 100644 --- a/react-packager/src/node-haste/__tests__/DependencyGraph-test.js +++ b/react-packager/src/node-haste/__tests__/DependencyGraph-test.js @@ -111,6 +111,11 @@ jest.mock('jest-haste-map/build/crawlers/node', () => { const mocksPattern = /(?:[\\/]|^)__mocks__[\\/]([^\/]+)\.js$/; +// This doesn't have state, and it's huge (Babel) so it's much faster to +// require it only once. +const extractDependencies = require('../../JSTransformer/worker/extract-dependencies'); +jest.mock('../../JSTransformer/worker/extract-dependencies', () => extractDependencies); + jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000; const path = require('path'); @@ -122,7 +127,6 @@ beforeEach(() => { describe('DependencyGraph', function() { let Module; - let extractDependencies; let defaults; function getOrderedDependenciesAsJSON(dgraph, entryPath, platform, recursive = true) { @@ -193,8 +197,6 @@ describe('DependencyGraph', function() { Cache.prototype.end = jest.genMockFn(); const transformCacheKey = 'abcdef'; - extractDependencies = - require('../../JSTransformer/worker/extract-dependencies'); defaults = { assetExts: ['png', 'jpg'], cache: new Cache(), @@ -2744,7 +2746,6 @@ describe('DependencyGraph', function() { jest.resetModules(); jest.mock('path', () => path.win32); DependencyGraph = require('../index'); - extractDependencies = require('../../JSTransformer/worker/extract-dependencies'); }); afterEach(function() {