Conversation
|
Is this a breaking change? |
|
@gyandeeps - it should not be. Is there an easy way to reproduce the failure you were seeing? |
|
Basically To be honest I havent bisected a lot to findout the real cause. |
|
Apologies for the trouble @gyandeeps. I'll try to find time to dig into the failures and make sense of what's going on. If any other reports come up, or if you would benefit from running tests on Node 7, I'll cut a release that reverts this change. |
|
Thanks for help @tschaub . We are planning to start doing node7 testing and for that we need to update the mock-fs. We would like a release of mock-fs with node7 updates but I would totally understand if you have reservations on it. If we can solve this in a easy way i am all of it. |
|
Hi, thanks for looking into this. I've also been investigating the // test.js
require('./foo.js').modifyValue();
require('mock-fs');
assert(require('./foo.js').getValue() === true);// foo.js
var value = false;
module.exports = {
modifyValue() {
value = true;
},
getValue() {
return value;
}
};This works with |
|
I think #103 was occurring due to something like this: // in fs-extra
module.exports = {
readFile: require('fs').readFile
};Since As an alternative to clearing the require cache, have you considered mutating the |
Due to a change in mock-fs 3.12.0, the `require` cache is cleared as soon as the mock-fs library is loaded (see tschaub/mock-fs#141). Our `lib/cli-engine.js` test uses `const Plugins = require('../../lib/plugins.js')` at the top level, and then some of the later tests use `require('mock-fs')` at the top level. Some of the `lib/cli-engine.js` tests have a requirement that `Plugins === require('../../lib/plugins.js')`, so using `require('mock-fs')` was causing the `require('../../lib/plugins.js')` value to change, which caused the tests to fail. This commit fixes the issue by moving the `const Plugins = require('../../lib/plugins.js')` into a `before` hook, so that it gets run *after* `mock-fs` is loaded.
|
@gyandeeps and @not-an-aardvark - I've reverted these changes and published @not-an-aardvark - yes, modifying |
|
@not-an-aardvark - See #182 for a work-in-progress PR that overrides only |
This makes things work in cases where another module requires
fs-extra(or similar) beforemocks-fsis required.Fixes #103.