Fix DependencyGraph-test in OS.

Reviewed By: davidaurelio

Differential Revision: D5113955

fbshipit-source-id: 892331815393ca314e84112551f516a20126068f
This commit is contained in:
Christoph Pojer 2017-05-23 16:11:47 -07:00 committed by Facebook Github Bot
parent 06bb33eba0
commit 20f7633d53
1 changed files with 14 additions and 5 deletions

View File

@ -22,11 +22,15 @@ jest
// This doesn't have state, and it's huge (Babel) so it's much faster to
// require it only once. The variable name is prefixed with "mock" as an escape-hatch
// for babel-plugin-jest-hoist.
const mockExtractDependencies = require('../../JSTransformer/worker/extract-dependencies');
jest.mock(
let mockExtractDependencies;
jest.mock('../../JSTransformer/worker/extract-dependencies', () => {
if (!mockExtractDependencies) {
mockExtractDependencies = require.requireActual(
'../../JSTransformer/worker/extract-dependencies',
() => mockExtractDependencies,
);
);
}
return mockExtractDependencies;
});
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
@ -98,6 +102,11 @@ describe('DependencyGraph', function() {
return new Promise(resolve => {
let deps = {dependencies: [], dependencyOffsets: []};
if (!module.path.endsWith('.json')) {
if (!mockExtractDependencies) {
mockExtractDependencies = require.requireActual(
'../../JSTransformer/worker/extract-dependencies',
);
}
deps = mockExtractDependencies(sourceCode);
}
resolve({...deps, code: sourceCode});