Make tests compatible with the latest Jest version

Reviewed By: cpojer

Differential Revision: D6419868

fbshipit-source-id: f01a3f4d54ca1aa3539d92363a51f70247642463
This commit is contained in:
Miguel Jimenez Esun 2017-11-28 03:08:08 -08:00 committed by Facebook Github Bot
parent ac2aa718c0
commit b282031517
2 changed files with 40 additions and 34 deletions

View File

@ -133,16 +133,19 @@ describe('traverseDependencies', function() {
let DependencyGraph;
let processDgraph;
const consoleWarn = console.warn;
const realPlatform = process.platform;
beforeEach(function() {
process.platform = 'linux';
Object.defineProperty(process, 'platform', {
configurable: true,
enumerable: true,
value: 'linux',
});
DependencyGraph = require('../../node-haste/DependencyGraph');
processDgraph = processDgraphFor.bind(null, DependencyGraph);
});
afterEach(function() {
console.warn = consoleWarn;
process.platform = realPlatform;
});
it('should get dependencies', async () => {
@ -2403,11 +2406,14 @@ describe('traverseDependencies', function() {
});
describe('get sync dependencies (win32)', () => {
const realPlatform = process.platform;
let DependencyGraph;
let processDgraph;
beforeEach(function() {
process.platform = 'win32';
Object.defineProperty(process, 'platform', {
configurable: true,
enumerable: true,
value: 'win32',
});
// reload path module
jest.resetModules();
@ -2416,10 +2422,6 @@ describe('traverseDependencies', function() {
processDgraph = processDgraphFor.bind(null, DependencyGraph);
});
afterEach(function() {
process.platform = realPlatform;
});
it('should get dependencies', async () => {
const root = 'C:\\root';
setMockFileSystem({
@ -2580,20 +2582,20 @@ describe('traverseDependencies', function() {
});
describe('node_modules (posix)', function() {
const realPlatform = process.platform;
let DependencyGraph;
let processDgraph;
beforeEach(function() {
process.platform = 'linux';
Object.defineProperty(process, 'platform', {
configurable: true,
enumerable: true,
value: 'linux',
});
DependencyGraph = require('../../node-haste/DependencyGraph');
processDgraph = processDgraphFor.bind(null, DependencyGraph);
});
afterEach(function() {
process.platform = realPlatform;
});
it('should work with nested node_modules', async () => {
var root = '/root';
setMockFileSystem({
@ -3524,11 +3526,15 @@ describe('traverseDependencies', function() {
});
describe('node_modules (win32)', function() {
const realPlatform = process.platform;
let DependencyGraph;
let processDgraph;
beforeEach(() => {
process.platform = 'win32';
Object.defineProperty(process, 'platform', {
configurable: true,
enumerable: true,
value: 'win32',
});
// reload path module
jest.resetModules();
jest.mock('path', () => require.requireActual('path').win32);
@ -3536,10 +3542,6 @@ describe('traverseDependencies', function() {
processDgraph = processDgraphFor.bind(null, DependencyGraph);
});
afterEach(() => {
process.platform = realPlatform;
});
it('should work with nested node_modules', async () => {
var root = 'C:\\root';
setMockFileSystem({
@ -4424,20 +4426,20 @@ describe('traverseDependencies', function() {
});
describe('file watch updating', function() {
const realPlatform = process.platform;
let DependencyGraph;
let processDgraph;
beforeEach(function() {
process.platform = 'linux';
Object.defineProperty(process, 'platform', {
configurable: true,
enumerable: true,
value: 'linux',
});
DependencyGraph = require('../../node-haste/DependencyGraph');
processDgraph = processDgraphFor.bind(null, DependencyGraph);
});
afterEach(function() {
process.platform = realPlatform;
});
it('updates module dependencies', async () => {
var root = '/root';
var filesystem = setMockFileSystem({
@ -5092,20 +5094,20 @@ describe('traverseDependencies', function() {
});
describe('Extensions', () => {
const realPlatform = process.platform;
let DependencyGraph;
let processDgraph;
beforeEach(function() {
process.platform = 'linux';
Object.defineProperty(process, 'platform', {
configurable: true,
enumerable: true,
value: 'linux',
});
DependencyGraph = require('../../node-haste/DependencyGraph');
processDgraph = processDgraphFor.bind(null, DependencyGraph);
});
afterEach(function() {
process.platform = realPlatform;
});
it('supports custom file extensions', async () => {
var root = '/root';
setMockFileSystem({

View File

@ -76,7 +76,11 @@ describe('Module', () => {
createModule({...options, file: '/root/package.json'});
beforeEach(function() {
process.platform = 'linux';
Object.defineProperty(process, 'platform', {
configurable: true,
enumerable: true,
value: 'linux',
});
cache = createCache();
transformCacheKey = 'abcdef';
transformCache.mock.reset();