mirror of https://github.com/status-im/metro.git
Fix DependencyGraph-test in OS.
Reviewed By: davidaurelio Differential Revision: D5113955 fbshipit-source-id: 892331815393ca314e84112551f516a20126068f
This commit is contained in:
parent
06bb33eba0
commit
20f7633d53
|
@ -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(
|
||||
'../../JSTransformer/worker/extract-dependencies',
|
||||
() => mockExtractDependencies,
|
||||
);
|
||||
let mockExtractDependencies;
|
||||
jest.mock('../../JSTransformer/worker/extract-dependencies', () => {
|
||||
if (!mockExtractDependencies) {
|
||||
mockExtractDependencies = require.requireActual(
|
||||
'../../JSTransformer/worker/extract-dependencies',
|
||||
);
|
||||
}
|
||||
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});
|
||||
|
|
Loading…
Reference in New Issue