From a66a231dfc694b169c4d3de0ccc1773c7766c683 Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Wed, 28 Feb 2018 02:28:15 -0800 Subject: [PATCH] metro: DeltaBundler-test: use memory-fs Reviewed By: rafeca Differential Revision: D7098504 fbshipit-source-id: 5c2c7b88b2a9b41f3c7d75613c7ab290622176ea --- .../__tests__/DeltaTransformer-test.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/packages/metro/src/DeltaBundler/__tests__/DeltaTransformer-test.js b/packages/metro/src/DeltaBundler/__tests__/DeltaTransformer-test.js index 2ea0cdd1..7b1ead04 100644 --- a/packages/metro/src/DeltaBundler/__tests__/DeltaTransformer-test.js +++ b/packages/metro/src/DeltaBundler/__tests__/DeltaTransformer-test.js @@ -10,7 +10,7 @@ 'use strict'; jest - .mock('fs') + .mock('fs', () => new (require('metro-memory-fs'))()) .mock('assert') .mock('progress') .mock('../DeltaCalculator') @@ -20,6 +20,7 @@ jest .mock('/path/to/transformer.js', () => ({}), {virtual: true}); const fs = require('fs'); +const mkdirp = require('mkdirp'); const Bundler = require('../../Bundler'); const DeltaTransformer = require('../DeltaTransformer'); @@ -53,16 +54,10 @@ describe('DeltaTransformer', () => { .fn() .mockImplementation(opts => Promise.resolve(new DependencyGraph(opts))); - fs.__setMockFilesystem({ - path: {to: {'transformer.js': ''}}, - root: {to: {'something.js': ''}}, - }); - - fs.statSync.mockImplementation(function() { - return { - isDirectory: () => true, - }; - }); + mkdirp.sync('/path/to'); + fs.writeFileSync('/path/to/transformer.js', ''); + mkdirp.sync('/root/to'); + fs.writeFileSync('/root/to/something.js', ''); bundler = new Bundler(bundlerOptions); });