From 290a0f691d83d4e0bc2163ec8b54c266277280fa Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Fri, 18 Feb 2022 12:43:27 +0100 Subject: [PATCH] test: deflake test-common-expect-warning The subprocess might exit before the data is flushed. Run the assertion after the `'end'` event is emitted. PR-URL: https://github.com/nodejs/node/pull/42046 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Darshan Sen --- test/parallel/test-common-expect-warning.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-common-expect-warning.js b/test/parallel/test-common-expect-warning.js index be3e385b11e0f4..dff32037fbb5b1 100644 --- a/test/parallel/test-common-expect-warning.js +++ b/test/parallel/test-common-expect-warning.js @@ -36,9 +36,11 @@ if (process.argv[2] !== 'child') { child.stderr.on('data', (data) => { stderr += data; }); + child.stderr.on('end', common.mustCall(() => { + assert.match(stderr, /Unexpected extra warning received/); + })); child.on('exit', common.mustCall((status) => { assert.notStrictEqual(status, 0); - assert.match(stderr, /Unexpected extra warning received/); })); } } else {