mirror of https://github.com/status-im/metro.git
Make tests compatible with the latest Jest version
Reviewed By: cpojer Differential Revision: D6419868 fbshipit-source-id: f01a3f4d54ca1aa3539d92363a51f70247642463
This commit is contained in:
parent
ac2aa718c0
commit
b282031517
|
@ -133,16 +133,19 @@ describe('traverseDependencies', function() {
|
||||||
let DependencyGraph;
|
let DependencyGraph;
|
||||||
let processDgraph;
|
let processDgraph;
|
||||||
const consoleWarn = console.warn;
|
const consoleWarn = console.warn;
|
||||||
const realPlatform = process.platform;
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
process.platform = 'linux';
|
Object.defineProperty(process, 'platform', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
value: 'linux',
|
||||||
|
});
|
||||||
|
|
||||||
DependencyGraph = require('../../node-haste/DependencyGraph');
|
DependencyGraph = require('../../node-haste/DependencyGraph');
|
||||||
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
console.warn = consoleWarn;
|
console.warn = consoleWarn;
|
||||||
process.platform = realPlatform;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should get dependencies', async () => {
|
it('should get dependencies', async () => {
|
||||||
|
@ -2403,11 +2406,14 @@ describe('traverseDependencies', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('get sync dependencies (win32)', () => {
|
describe('get sync dependencies (win32)', () => {
|
||||||
const realPlatform = process.platform;
|
|
||||||
let DependencyGraph;
|
let DependencyGraph;
|
||||||
let processDgraph;
|
let processDgraph;
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
process.platform = 'win32';
|
Object.defineProperty(process, 'platform', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
value: 'win32',
|
||||||
|
});
|
||||||
|
|
||||||
// reload path module
|
// reload path module
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
|
@ -2416,10 +2422,6 @@ describe('traverseDependencies', function() {
|
||||||
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
|
||||||
process.platform = realPlatform;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get dependencies', async () => {
|
it('should get dependencies', async () => {
|
||||||
const root = 'C:\\root';
|
const root = 'C:\\root';
|
||||||
setMockFileSystem({
|
setMockFileSystem({
|
||||||
|
@ -2580,18 +2582,18 @@ describe('traverseDependencies', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('node_modules (posix)', function() {
|
describe('node_modules (posix)', function() {
|
||||||
const realPlatform = process.platform;
|
|
||||||
let DependencyGraph;
|
let DependencyGraph;
|
||||||
let processDgraph;
|
let processDgraph;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
process.platform = 'linux';
|
Object.defineProperty(process, 'platform', {
|
||||||
DependencyGraph = require('../../node-haste/DependencyGraph');
|
configurable: true,
|
||||||
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
enumerable: true,
|
||||||
|
value: 'linux',
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
DependencyGraph = require('../../node-haste/DependencyGraph');
|
||||||
process.platform = realPlatform;
|
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should work with nested node_modules', async () => {
|
it('should work with nested node_modules', async () => {
|
||||||
|
@ -3524,11 +3526,15 @@ describe('traverseDependencies', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('node_modules (win32)', function() {
|
describe('node_modules (win32)', function() {
|
||||||
const realPlatform = process.platform;
|
|
||||||
let DependencyGraph;
|
let DependencyGraph;
|
||||||
let processDgraph;
|
let processDgraph;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
process.platform = 'win32';
|
Object.defineProperty(process, 'platform', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
value: 'win32',
|
||||||
|
});
|
||||||
|
|
||||||
// reload path module
|
// reload path module
|
||||||
jest.resetModules();
|
jest.resetModules();
|
||||||
jest.mock('path', () => require.requireActual('path').win32);
|
jest.mock('path', () => require.requireActual('path').win32);
|
||||||
|
@ -3536,10 +3542,6 @@ describe('traverseDependencies', function() {
|
||||||
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
process.platform = realPlatform;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should work with nested node_modules', async () => {
|
it('should work with nested node_modules', async () => {
|
||||||
var root = 'C:\\root';
|
var root = 'C:\\root';
|
||||||
setMockFileSystem({
|
setMockFileSystem({
|
||||||
|
@ -4424,18 +4426,18 @@ describe('traverseDependencies', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('file watch updating', function() {
|
describe('file watch updating', function() {
|
||||||
const realPlatform = process.platform;
|
|
||||||
let DependencyGraph;
|
let DependencyGraph;
|
||||||
let processDgraph;
|
let processDgraph;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
process.platform = 'linux';
|
Object.defineProperty(process, 'platform', {
|
||||||
DependencyGraph = require('../../node-haste/DependencyGraph');
|
configurable: true,
|
||||||
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
enumerable: true,
|
||||||
|
value: 'linux',
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
DependencyGraph = require('../../node-haste/DependencyGraph');
|
||||||
process.platform = realPlatform;
|
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('updates module dependencies', async () => {
|
it('updates module dependencies', async () => {
|
||||||
|
@ -5092,18 +5094,18 @@ describe('traverseDependencies', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Extensions', () => {
|
describe('Extensions', () => {
|
||||||
const realPlatform = process.platform;
|
|
||||||
let DependencyGraph;
|
let DependencyGraph;
|
||||||
let processDgraph;
|
let processDgraph;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
process.platform = 'linux';
|
Object.defineProperty(process, 'platform', {
|
||||||
DependencyGraph = require('../../node-haste/DependencyGraph');
|
configurable: true,
|
||||||
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
enumerable: true,
|
||||||
|
value: 'linux',
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
DependencyGraph = require('../../node-haste/DependencyGraph');
|
||||||
process.platform = realPlatform;
|
processDgraph = processDgraphFor.bind(null, DependencyGraph);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('supports custom file extensions', async () => {
|
it('supports custom file extensions', async () => {
|
||||||
|
|
|
@ -76,7 +76,11 @@ describe('Module', () => {
|
||||||
createModule({...options, file: '/root/package.json'});
|
createModule({...options, file: '/root/package.json'});
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
process.platform = 'linux';
|
Object.defineProperty(process, 'platform', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
value: 'linux',
|
||||||
|
});
|
||||||
cache = createCache();
|
cache = createCache();
|
||||||
transformCacheKey = 'abcdef';
|
transformCacheKey = 'abcdef';
|
||||||
transformCache.mock.reset();
|
transformCache.mock.reset();
|
||||||
|
|
Loading…
Reference in New Issue