Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions test/parallel/test-watch-file-shared-dependency.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,22 @@ describe('watch file with shared dependency', () => {
const controller = new AbortController();
const watcher = new FilesWatcher({ signal: controller.signal });

watcher.on('changed', common.mustCall(({ owners }) => {
if (owners.size !== 2) return;

// If this code is never reached the test times out.
const onExpectedOwners = common.mustCall(({ owners }) => {
assert.ok(owners.has(fixturePaths['test.js']));
assert.ok(owners.has(fixturePaths['test-2.js']));
controller.abort();
done();
}));
});

function onChanged({ owners }) {
if (owners.size !== 2) return;

// If this code is never reached the test times out.
watcher.removeListener('changed', onChanged);
onExpectedOwners({ owners });
}

watcher.on('changed', onChanged);
watcher.filterFile(fixturePaths['test.js']);
watcher.filterFile(fixturePaths['test-2.js']);
watcher.filterFile(fixturePaths['dependency.js'], fixturePaths['test.js']);
Expand Down
Loading