diff --git a/doc/api/fs.md b/doc/api/fs.md index 15723a2a288752..c8c1c19fee9004 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2406,7 +2406,7 @@ this improves the usability of file watching. This is expected behavior. Providing `filename` argument in the callback is only supported on Linux, -macOS, and Windows. Even on supported platforms, `filename` is not always +macOS, Windows, and AIX. Even on supported platforms, `filename` is not always guaranteed to be provided. Therefore, don't assume that `filename` argument is always provided in the callback, and have some fallback logic if it is null. diff --git a/test/parallel/test-fs-watchfile.js b/test/parallel/test-fs-watchfile.js index 3e8f2e22a5904a..fe22f93a10e044 100644 --- a/test/parallel/test-fs-watchfile.js +++ b/test/parallel/test-fs-watchfile.js @@ -64,24 +64,20 @@ fs.watchFile(enoentFile, {interval: 0}, common.mustCall(function(curr, prev) { } }, 2)); -// Watch events should callback with a filename -if (common.isLinux || common.isOSX) { +// Watch events should callback with a filename on supported systems +if (common.isLinux || common.isOSX || common.isWindows || common.isAix) { const dir = common.tmpDir + '/watch'; fs.mkdir(dir, common.mustCall(function(err) { - assert(!err); + if (err) assert.fail(err); fs.watch(dir, common.mustCall(function(eventType, filename) { this._handle.close(); - common.refreshTmpDir(); assert.strictEqual(filename, 'foo.txt'); })); - fs.writeFile(`${dir}/foo.txt`, 'foo', common.mustCall((err) => { - if (err) { - common.refreshTmpDir(); - assert(!err); - } + fs.writeFile(`${dir}/foo.txt`, 'foo', common.mustCall(function(err) { + if (err) assert.fail(err); })); })); }