Skip to content

Commit

Permalink
Confirm that mock-fs works if another file requires fs-extra first
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaub committed Jul 9, 2016
1 parent 51bc0fb commit 97c89a5
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"chai": "3.5.0",
"eslint": "2.13.0",
"eslint-config-tschaub": "5.0.0",
"fs-extra": "^0.30.0",
"mocha": "2.5.2",
"rimraf": "2.5.2"
},
Expand Down
File renamed without changes.
15 changes: 15 additions & 0 deletions test/integration/A.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* This test is here so that fs-extra is required before mock-fs in the
* B.spec.js file.
*
* See https://github.com/tschaub/mock-fs/issues/103
*/

var assert = require('../helper').assert;
var fs = require('fs-extra');

describe('Dummy test A', function() {
it('should pass', function() {
assert.equal(typeof fs, 'object');
});
});
28 changes: 28 additions & 0 deletions test/integration/B.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* The A.spec.js file requires fs-extra before this one. Here we confirm that
* mock-fs still works even if fs-extra was required elsewhere first.
*
* See https://github.com/tschaub/mock-fs/issues/103
*/

var assert = require('../helper').assert;
var mock = require('../../lib/index');
var fs = require('fs-extra');

describe('Dummy test B', function() {
before(function() {
mock({
folder: {}
});
});

after(function() {
mock.restore();
});

it('should read mocked directory', function() {
var content = fs.readdirSync('folder');
assert.isArray(content);
});

});

0 comments on commit 97c89a5

Please sign in to comment.