Closed begin-again closed 6 years ago
It works - accessSync does not have a return value. It throws an error if the flags are not compatible. See: https://nodejs.org/api/fs.html#fs_fs_accesssync_path_mode
Try this instead:
const fs = require('fs');
const fakeFS = require('mock-fs');
const assert = require('assert')
fakeFS({
'./fakeFile': { }
});
assert.doesNotThrow(() => fs.accessSync('./fakeFile', fs.constants.F_OK));
assert.throws(() => fs.accessSync('./bad/file/path', fs.constants.F_OK));
@maxwellgerber's answer looks right to me. Please reopen if you find the mock-fs
behavior different than regular fs
behavior.
Does
accessSync
not work with this library? The below assert is returning undefinedAssertionError [ERR_ASSERTION]: undefined == true