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() {