Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: deflake test-watch-file-shared-dependency #56344

Merged
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
27 changes: 21 additions & 6 deletions test/parallel/test-watch-file-shared-dependency.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ if (common.isIBMi)
if (common.isAIX)
common.skip('folder watch capability is limited in AIX.');

tmpdir.refresh();

const { FilesWatcher } = watcher;

tmpdir.refresh();
Expand All @@ -32,15 +30,18 @@ Object.entries(fixtureContent)
.forEach(([file, content]) => writeFileSync(fixturePaths[file], content));

describe('watch file with shared dependency', () => {
it('should not remove shared dependencies when unfiltering an owner', () => {
it('should not remove shared dependencies when unfiltering an owner', (t, done) => {
const controller = new AbortController();
const watcher = new FilesWatcher({ signal: controller.signal, debounce: 200 });
const watcher = new FilesWatcher({ signal: controller.signal });

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

// If this code is never reached the test times out.
assert.ok(owners.has(fixturePaths['test.js']));
assert.ok(owners.has(fixturePaths['test-2.js']));
controller.abort();
done();
});
watcher.filterFile(fixturePaths['test.js']);
watcher.filterFile(fixturePaths['test-2.js']);
Expand All @@ -49,6 +50,20 @@ describe('watch file with shared dependency', () => {
watcher.unfilterFilesOwnedBy([fixturePaths['test.js']]);
watcher.filterFile(fixturePaths['test.js']);
watcher.filterFile(fixturePaths['dependency.js'], fixturePaths['test.js']);
writeFileSync(fixturePaths['dependency.js'], 'module.exports = { modified: true };');

if (common.isMacOS) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be flaky only on macOS.

// Do the write with a delay to ensure that the OS is ready to notify us.
setTimeout(() => {
writeFileSync(
fixturePaths['dependency.js'],
'module.exports = { modified: true };'
);
}, common.platformTimeout(200));
} else {
writeFileSync(
fixturePaths['dependency.js'],
'module.exports = { modified: true };'
);
}
});
});
Loading