Environment Info:
$ node --version
v11.2.0
$ npm --version
6.4.1
$ nvm --version
0.33.11
MockFS version: 4.7.0
We recently found one test using mock-fs that fails consistently in Node.js v11:
https://travis-ci.org/eslint/eslint/jobs/456094527#L484
This occurs because existsSync ends up throwing an error instead of returning false (which it does consistently in other Node.js versions).
The test in question looks like this:
describe("checkPackageJson()", () => {
after(() => {
mockFs.restore();
});
it("should return true if package.json exists", () => {
mockFs({
"package.json": "{ \"file\": \"contents\" }"
});
assert.strictEqual(npmUtils.checkPackageJson(), true);
});
it("should return false if package.json does not exist", () => {
mockFs({});
assert.strictEqual(npmUtils.checkPackageJson(), false);
});
});
The first test passes while the second one throws an error in Node.js 11 (Node.js 6, 8, and 10 all pass). npmUtils.checkPackageJson() calls fs.existsSync under the covers.
Environment Info:
MockFS version: 4.7.0
We recently found one test using
mock-fsthat fails consistently in Node.js v11:https://travis-ci.org/eslint/eslint/jobs/456094527#L484
This occurs because
existsSyncends up throwing an error instead of returningfalse(which it does consistently in other Node.js versions).The test in question looks like this:
The first test passes while the second one throws an error in Node.js 11 (Node.js 6, 8, and 10 all pass).
npmUtils.checkPackageJson()callsfs.existsSyncunder the covers.