test: ignore unrelated events in FW watch tests

Change assertions on `test-fs-watch-recursive-add-*` tests to only take
into account change events that match the file.

PR-URL: https://github.com/nodejs/node/pull/55605
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Carlos Espa 2024-11-06 02:10:33 +01:00 committed by GitHub
parent 4da8d110f3
commit 42f465972a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 16 additions and 32 deletions

View file

@ -40,9 +40,8 @@ const relativePath = path.join(file, path.basename(subfolderPath), childrenFile)
const watcher = fs.watch(testDirectory, { recursive: true });
let watcherClosed = false;
watcher.on('change', function(event, filename) {
assert.strictEqual(event, 'rename');
if (filename === relativePath) {
assert.strictEqual(event, 'rename');
watcher.close();
watcherClosed = true;
}