From dc4398c9cfb86754f69631a9e69da4314ac0cbea Mon Sep 17 00:00:00 2001 From: Moshe Atlow Date: Sun, 25 Sep 2022 14:07:56 +0300 Subject: [PATCH] test: fix watch mode test flake PR-URL: https://github.com/nodejs/node/pull/44739 Fixes: https://github.com/nodejs/node/issues/44735 Reviewed-By: Erick Wendel Reviewed-By: Rafael Gonzaga Reviewed-By: Benjamin Gruenbaum --- test/sequential/test-watch-mode.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/sequential/test-watch-mode.mjs b/test/sequential/test-watch-mode.mjs index bfe8f08f94c08e..e24fb97ad234a8 100644 --- a/test/sequential/test-watch-mode.mjs +++ b/test/sequential/test-watch-mode.mjs @@ -94,8 +94,10 @@ describe('watch mode', { concurrency: true, timeout: 60_0000 }, () => { const file = fixtures.path('watch-mode/failing.js'); const { stderr, stdout } = await spawnWithRestarts({ file }); + // Use match first to pretty print diff on failure assert.match(stderr, /Error: fails\r?\n/); - assert.strictEqual(stderr.match(/Error: fails\r?\n/g).length, 2); + // Test that failures happen once per restart + assert(stderr.match(/Error: fails\r?\n/g).length >= 2); assertRestartedCorrectly({ stdout, messages: { completed: `Failed running ${inspect(file)}`, restarted: `Restarting ${inspect(file)}` },