Skip to content
Merged
Changes from 1 commit
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
8 changes: 5 additions & 3 deletions test/parallel/test-runner-watch-mode-complex.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,17 @@ describe('test runner watch mode with more complex setup', () => {
runs.push(currentRun);
currentRun = '';
const fileToDeletePathLocal = tmpdir.resolve('test-to-delete.mjs');
unlinkSync(fileToDeletePathLocal);
await new Promise((resolve) => setTimeout(() => {
unlinkSync(fileToDeletePathLocal);
resolve();
}, common.platformTimeout(1000)));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can/Should this be simplified with node:timers/promises?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't think about it, thanks for the suggestion, I'll take a look 😁

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would using node:fs/promises be enough here? It seems weird to have to put a sync operation in an async one

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hey @aduh95, yes, no problem at all.
The only important logic is the "sleep" after the delete to ensure that the watcher has received the event and completed the test run before proceeding.
Thanks for your feedback, I'll fixit ASAP 😁

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

just update 😁


const content = fixtureContent['dependency.mjs'];
const path = fixturePaths['dependency.mjs'];
const interval = setInterval(() => writeFileSync(path, content), common.platformTimeout(1000));
setTimeout(() => writeFileSync(path, content), common.platformTimeout(1000));
await ran2.promise;
runs.push(currentRun);
currentRun = '';
clearInterval(interval);
child.kill();

assert.strictEqual(runs.length, 2);
Expand Down