Skip to content

test: fix test-watch-mode

This PR fixes flakiness in watch mode tests in test/sequential/test-watch-mode.mjs. The changes made introduce a basic synchronization between restarting the process (rewriting the file) and its execution. Previously, it was possible to restart the process while it was still executing which caused logs to appear in an unexpected order, thus failing the assertions in various test cases.

With these changes, one problem still persists. Rarely, in less than 1% of runs, logs from the start of the process, until the first restart are missing. Eg. instead of getting

Completed running 'C:\\_work\\node\\test\\.tmp.0\\12.js'
Restarting 'C:\\_work\\node\\test\\.tmp.0\\12.js'
Completed running 'C:\\_work\\node\\test\\.tmp.0\\12.js'

test gets

Restarting 'C:\\_work\\node\\test\\.tmp.0\\12.js'
Completed running 'C:\\_work\\node\\test\\.tmp.0\\12.js'

This behavior seems to be random, and by the looks of it, it's related to watch mode in a more general way, not directly related to these tests. It should probably be addressed in a separate issue and PR.

Refs: https://github.com/nodejs/node/issues/44898

Merge request reports

Loading