diff --git a/test/parallel/test-fs-close-errors.js b/test/parallel/test-fs-close-errors.js index 42d990410f9848..6168d5c20ab8e5 100644 --- a/test/parallel/test-fs-close-errors.js +++ b/test/parallel/test-fs-close-errors.js @@ -17,3 +17,19 @@ const fs = require('fs'); assert.throws(() => fs.close(input), errObj); assert.throws(() => fs.closeSync(input), errObj); }); + +{ + // Test error when cb is not a function + const fd = fs.openSync(__filename, 'r'); + + const errObj = { + code: 'ERR_INVALID_CALLBACK', + name: 'TypeError' + }; + + ['', false, null, {}, []].forEach((input) => { + assert.throws(() => fs.close(fd, input), errObj); + }); + + fs.closeSync(fd); +}