From b19f339bcf613a8bb3b1b8f370e0e2043f93a2b7 Mon Sep 17 00:00:00 2001 From: christian-bromann Date: Fri, 12 Oct 2018 10:43:58 -0700 Subject: [PATCH] test: increase coverage for readfile with withFileTypes According to the test coverage report a test case was missings checking if an error is passed into the callback for readdir calls with withFileTypes option. PR-URL: https://github.com/nodejs/node/pull/23557 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell --- test/parallel/test-fs-readdir-types.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/parallel/test-fs-readdir-types.js b/test/parallel/test-fs-readdir-types.js index 0faaeb00dadeb1..fa179eccfe26eb 100644 --- a/test/parallel/test-fs-readdir-types.js +++ b/test/parallel/test-fs-readdir-types.js @@ -49,6 +49,19 @@ function assertDirents(dirents) { // Check the readdir Sync version assertDirents(fs.readdirSync(readdirDir, { withFileTypes: true })); +fs.readdir(__filename, { + withFileTypes: true +}, common.mustCall((err) => { + assert.throws( + () => { throw err; }, + { + code: 'ENOTDIR', + name: 'Error', + message: `ENOTDIR: not a directory, scandir '${__filename}'` + } + ); +})); + // Check the readdir async version fs.readdir(readdirDir, { withFileTypes: true