mirror of https://github.com/status-im/metro.git
Disable automocking from tests
Summary: We are flipping the switch all over Facebook, now that this part of the code is isolated we can do it in Metro as well. Reviewed By: davidaurelio Differential Revision: D5199449 fbshipit-source-id: 20c1bacc6dd2d314bd76bc5cc0ecd13266bf81c6
This commit is contained in:
parent
01ecd43c62
commit
5e6d70d4d6
|
@ -46,19 +46,10 @@
|
|||
"watch": "yarn run build --silent && node ./scripts/watch.js"
|
||||
},
|
||||
"jest": {
|
||||
"automock": true,
|
||||
"testEnvironment": "node",
|
||||
"timers": "fake",
|
||||
"setupFiles": [
|
||||
"<rootDir>/scripts/setupJest.js"
|
||||
],
|
||||
"unmockedModulePathPatterns": [
|
||||
"promise",
|
||||
"source-map",
|
||||
"denodeify",
|
||||
"fbjs",
|
||||
"sinon",
|
||||
"core-js"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
jest.mock('fs');
|
||||
|
||||
const AssetServer = require('../');
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const Bundle = require('../Bundle');
|
||||
const ModuleTransport = require('../../lib/ModuleTransport');
|
||||
const crypto = require('crypto');
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
jest
|
||||
.setMock('worker-farm', () => () => undefined)
|
||||
.setMock('../../worker-farm', () => () => undefined)
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const B64Builder = require('../B64Builder');
|
||||
|
||||
let builder;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const Generator = require('../Generator');
|
||||
|
||||
const {objectContaining} = expect;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const Generator = require('../Generator');
|
||||
const {compactMapping, fromRawMappings} = require('..');
|
||||
|
||||
|
|
|
@ -9,18 +9,10 @@
|
|||
'use strict';
|
||||
|
||||
jest
|
||||
.unmock('stream')
|
||||
.unmock('crypto')
|
||||
.unmock('../../lib/ModuleTransport')
|
||||
.unmock('../');
|
||||
|
||||
const fs = {writeFileSync: jest.fn()};
|
||||
const temp = {path: () => '/arbitrary/path'};
|
||||
const workerFarm = jest.fn();
|
||||
jest.setMock('fs', fs);
|
||||
jest.setMock('temp', temp);
|
||||
jest.setMock('worker-farm', workerFarm);
|
||||
jest.setMock('../../worker-farm', workerFarm);
|
||||
.mock('fs', () => ({writeFileSync: jest.fn()}))
|
||||
.mock('temp', () => ({path: () => '/arbitrary/path'}))
|
||||
.mock('worker-farm', () => jest.fn())
|
||||
.mock('../../worker-farm', () => jest.fn());
|
||||
|
||||
var Transformer = require('../');
|
||||
|
||||
|
@ -37,6 +29,8 @@ describe('Transformer', function() {
|
|||
Cache = jest.fn();
|
||||
Cache.prototype.get = jest.fn((a, b, c) => c());
|
||||
|
||||
const fs = require('fs');
|
||||
const workerFarm = require('../../worker-farm');
|
||||
fs.writeFileSync.mockClear();
|
||||
workerFarm.mockClear();
|
||||
workerFarm.mockImplementation((opts, path, methods) => {
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
const babel = require('babel-core');
|
||||
const constantFolding = require('../constant-folding');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const extractDependencies = require('../extract-dependencies');
|
||||
|
||||
describe('Dependency extraction:', () => {
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
/* eslint-disable max-len */
|
||||
|
||||
jest.disableAutomock();
|
||||
const inline = require('../inline');
|
||||
const {transform, transformFromAst} = require('babel-core');
|
||||
|
||||
|
|
|
@ -8,17 +8,14 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const uglify = {
|
||||
jest.mock('uglify-js', () => ({
|
||||
minify: jest.fn(code => {
|
||||
return {
|
||||
code: code.replace(/(^|\W)\s+/g, '$1'),
|
||||
map: {},
|
||||
};
|
||||
}),
|
||||
};
|
||||
jest.setMock('uglify-js', uglify);
|
||||
}));
|
||||
|
||||
const minify = require('../minify');
|
||||
const {objectContaining} = jasmine;
|
||||
|
@ -27,8 +24,10 @@ describe('Minification:', () => {
|
|||
const filename = '/arbitrary/file.js';
|
||||
const code = 'arbitrary(code)';
|
||||
let map;
|
||||
let uglify;
|
||||
|
||||
beforeEach(() => {
|
||||
uglify = require('uglify-js');
|
||||
uglify.minify.mockClear();
|
||||
uglify.minify.mockReturnValue({code: '', map: '{}'});
|
||||
map = {version: 3, sources: ['?'], mappings: ''};
|
||||
|
|
|
@ -8,11 +8,10 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
jest.mock('../constant-folding');
|
||||
jest.mock('../extract-dependencies');
|
||||
jest.mock('../inline');
|
||||
jest.mock('../minify');
|
||||
jest.mock('../constant-folding')
|
||||
.mock('../extract-dependencies')
|
||||
.mock('../inline')
|
||||
.mock('../minify');
|
||||
|
||||
const {objectContaining} = jasmine;
|
||||
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const {
|
||||
createEntry,
|
||||
createActionStartEntry,
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
'use strict';
|
||||
|
||||
jest
|
||||
.disableAutomock()
|
||||
.useRealTimers()
|
||||
.mock('console');
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const ModuleGraph = require('../ModuleGraph');
|
||||
const defaults = require('../../defaults');
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
'use strict';
|
||||
|
||||
declare var jest: any;
|
||||
jest.disableAutomock();
|
||||
|
||||
const indexedRamBundle = require('../indexed-ram-bundle');
|
||||
const {addModuleIdsToModuleWrapper} = require('../util');
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const {match} = require('sinon');
|
||||
const {fn} = require('../../test-helpers');
|
||||
const {
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const collectDependencies = require('../collect-dependencies');
|
||||
const astFromCode = require('babylon').parse;
|
||||
const {codeFromAst, comparableCode} = require('../../test-helpers');
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const optimizeModule = require('../optimize-module');
|
||||
const transformModule = require('../transform-module');
|
||||
const transformer = require('../../../transformer.js');
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const transformModule = require('../transform-module');
|
||||
|
||||
const t = require('babel-types');
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
'use strict';
|
||||
|
||||
jest
|
||||
.disableAutomock()
|
||||
.setMock('fs', jest.genMockFromModule('fs'))
|
||||
.mock('fs', () => jest.genMockFromModule('fs'))
|
||||
.mock('mkdirp');
|
||||
|
||||
const wrapWorkerFn = require('../wrap-worker-fn');
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
jest.useRealTimers();
|
||||
|
||||
jest.unmock('../');
|
||||
jest.unmock('../../defaults');
|
||||
jest.mock('path');
|
||||
|
||||
const {join: pathJoin} = require.requireActual('path');
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
describe('Object (ES7)', () => {
|
||||
beforeEach(() => {
|
||||
delete Object.entries;
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.dontMock('../MultipartResponse');
|
||||
|
||||
const MultipartResponse = require('../MultipartResponse');
|
||||
|
||||
describe('MultipartResponse', () => {
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
jest.mock('../../worker-farm', () => () => () => {})
|
||||
.mock('worker-farm', () => () => () => {})
|
||||
.mock('timers', () => ({setImmediate: fn => setTimeout(fn, 0)}))
|
||||
|
|
|
@ -8,9 +8,8 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
jest.mock('child_process');
|
||||
jest.mock('net');
|
||||
jest.mock('child_process')
|
||||
.mock('net');
|
||||
|
||||
const EventEmitter = require('events');
|
||||
const {Readable} = require('stream');
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const {LazyPromise, LockingPromise} = require('../util');
|
||||
|
||||
describe('Lazy Promise', () => {
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const SourceMapGenerator = require('../../../Bundler/source-map/Generator');
|
||||
const {symbolicate} = require('../worker');
|
||||
|
||||
|
|
|
@ -11,11 +11,9 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
jest.useRealTimers();
|
||||
|
||||
jest.dontMock('fs');
|
||||
jest.dontMock('graceful-fs');
|
||||
jest.useRealTimers()
|
||||
.unmock('fs')
|
||||
.unmock('graceful-fs');
|
||||
|
||||
/**
|
||||
* Don't waste time creating a worker-farm from jest-haste-map, use the function
|
||||
|
|
|
@ -9,9 +9,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest
|
||||
.useRealTimers()
|
||||
.dontMock('../BatchProcessor');
|
||||
jest.useRealTimers();
|
||||
|
||||
const BatchProcessor = require('../BatchProcessor');
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
jest.useRealTimers();
|
||||
|
||||
const mockFetch = jest.fn();
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest.dontMock('../TerminalClass').dontMock('lodash/throttle');
|
||||
|
||||
jest.mock('readline', () => ({
|
||||
moveCursor: (stream, dx, dy) => {
|
||||
const {cursor, columns} = stream;
|
||||
|
|
|
@ -9,13 +9,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest
|
||||
.dontMock('json-stable-stringify')
|
||||
.dontMock('../TransformCaching')
|
||||
.dontMock('left-pad')
|
||||
.dontMock('lodash/throttle')
|
||||
.dontMock('crypto');
|
||||
|
||||
const crypto = require('crypto');
|
||||
const jsonStableStringify = require('json-stable-stringify');
|
||||
|
||||
|
@ -32,6 +25,7 @@ jest.mock('fs', () => ({
|
|||
// Not required for it to work.
|
||||
return [];
|
||||
},
|
||||
mkdirSync: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('write-file-atomic', () => ({
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.autoMockOff();
|
||||
|
||||
const AssetModule = require('../AssetModule');
|
||||
|
||||
describe('AssetModule:', () => {
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const AssetResolutionCache = require('../AssetResolutionCache');
|
||||
|
||||
const MOCK_FILE_NAMES = [
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
jest.useRealTimers();
|
||||
jest
|
||||
.mock('fs')
|
||||
|
|
|
@ -8,21 +8,18 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest
|
||||
.dontMock('absolute-path')
|
||||
.dontMock('json-stable-stringify')
|
||||
.dontMock('crypto')
|
||||
.dontMock('../DependencyGraph/docblock')
|
||||
.dontMock('../Module');
|
||||
|
||||
jest
|
||||
.mock('fs');
|
||||
jest.mock('fs')
|
||||
.mock('graceful-fs')
|
||||
.mock('../ModuleCache')
|
||||
.mock('../DependencyGraph/DependencyGraphHelpers')
|
||||
.mock('../../lib/TransformCaching');
|
||||
|
||||
console.log(require.resolve('../../lib/TransformCaching'));
|
||||
const Module = require('../Module');
|
||||
const ModuleCache = require('../ModuleCache');
|
||||
const DependencyGraphHelpers = require('../DependencyGraph/DependencyGraphHelpers');
|
||||
const TransformCaching = require('../../lib/TransformCaching');
|
||||
const fs = require('graceful-fs');
|
||||
const fs = require('fs');
|
||||
|
||||
const packageJson =
|
||||
JSON.stringify({
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.dontMock('../parsePlatformFilePath')
|
||||
.dontMock('../AssetPaths');
|
||||
|
||||
var AssetPaths = require('../AssetPaths');
|
||||
|
||||
const TEST_PLATFORMS = new Set(['ios', 'android']);
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
jest.disableAutomock();
|
||||
|
||||
const MapWithDefaults = require('../MapWithDefaults');
|
||||
|
||||
describe('MapWithDefaults', function() {
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*/
|
||||
'use strict';
|
||||
|
||||
jest.dontMock('../parsePlatformFilePath');
|
||||
|
||||
var parsePlatformFilePath = require('../parsePlatformFilePath');
|
||||
|
||||
const TEST_PLATFORMS = new Set(['ios', 'android']);
|
||||
|
|
Loading…
Reference in New Issue