-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running with tests that don't use mockfs #103
Comments
I have faced the same problem. Would love to see elegant way to get round. |
It would be useful to see a simple example that reproduces the issue. |
Here is an example that reproduces the issue: https://github.com/goliney/mock-fs-103 /* A.js - runs first */
const expect = require('chai').expect;
//const mock = require('mock-fs'); //uncommenting this line solves the problem
const fs = require('fs-extra');
describe('Dummy test A', function () {
it('should pass', function () {
expect(true).to.be.true;
});
}); /* B.js - runs after */
const expect = require('chai').expect;
const mock = require('mock-fs');
const 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');
expect(content).to.be.an.array;
});
}); |
Looks like |
Ok. That got boring. I pushed another change to stop running tests on Node 0.8. |
I've reverted #141 since it introduced new problems. Will need to revisit this. |
Hi @tschaub, I met the same problem, every files can't be found with fs-extra. Do you any news about it ? :) thank you |
testing with jest I've been able to isolate mock-fs to a describe block and simply call |
I had some issues running unit tests (in mocha) with a
mock-fs
setup for a module that was also included in other tested modules, whose tests did not make use ofmock-fs
. This would only happen if the tests that did not usemock-fs
ran first - so it seemed there was an issue with non-overridden modules being cached.My solution was to add this to the top of test files that used
mock-fs
:I'm wondering if there's a better way to do this, or if it would be helpful to add this to the documentation?
The text was updated successfully, but these errors were encountered: