tschaub / mock-fs

Configurable mock for the fs module
https://npmjs.org/package/mock-fs
Other
908 stars 86 forks source link

fs.promises.access does not reject, causes unhandled rejection #280

Closed FINDarkside closed 4 years ago

FINDarkside commented 5 years ago

Promise returned by fs.promises.access is not rejected when it should be.

Code to reproduce (4.10.3):

const mockFs = require('mock-fs');
mockFs({
    './tmp.json': Buffer.from('fileContent'),
});
const fs = require('fs').promises;

async function test() {
    await fs.access('./doesNotExist');
    console.log('success');
}

test();

Output:

success
(node:6292) UnhandledPromiseRejectionWarning: Error: ENOENT, UV_ENOENT '\\?\C:\Users\Username\Dir\mocfsTest\doesNotExist'
    at Object.<anonymous> (C:\Users\Username\Dir\mocfsTest\node_modules\mock-fs\lib\binding.js:1435:13)
    at maybeCallback (C:\Users\Username\Dir\mocfsTest\node_modules\mock-fs\lib\binding.js:57:18)
    at Object.Binding.access (C:\Users\Username\Dir\mocfsTest\node_modules\mock-fs\lib\binding.js:1423:3)
    at Object.<anonymous> (C:\Users\Username\Dir\mocfsTest\node_modules\mock-fs\lib\index.js:33:39)
    at Object.access (internal/fs/promises.js:188:18)
    at test (C:\Users\Username\Dir\mocfsTest\index.js:8:14)
    at Object.<anonymous> (C:\Users\Username\Dir\mocfsTest\index.js:12:1)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)