From 7830a0b7b8e4b0467f9dfeea94f705c20eb7e76b 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. --- 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 {