From b0b268f5a247e2e6aabd63cab60cef291665201b Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Thu, 28 May 2020 21:03:49 +0200 Subject: [PATCH] test: fix flaky fs-construct test Fixes: https://github.com/nodejs/node/issues/33607 PR-URL: https://github.com/nodejs/node/pull/33625 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen --- test/parallel/test-fs-stream-construct.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-fs-stream-construct.js b/test/parallel/test-fs-stream-construct.js index 4e6bf0285fc91e..4e687838f6b0c8 100644 --- a/test/parallel/test-fs-stream-construct.js +++ b/test/parallel/test-fs-stream-construct.js @@ -199,11 +199,14 @@ const examplePath = fixtures.path('x.txt'); }); }); - const w = new WriteStream(`${tmpdir.path}/dummy2`, - { flags: 'wx+', emitClose: true }) - .on('error', common.mustCall((err) => { - assert.strictEqual(err.code, 'EEXIST'); - w.destroy(); - w.on('close', common.mustCall()); - })); + fs.open(`${tmpdir.path}/dummy3`, 'wx+', common.mustCall((err) => { + assert(!err); + const w = new WriteStream(`${tmpdir.path}/dummy3`, + { flags: 'wx+', emitClose: true }) + .on('error', common.mustCall((err) => { + assert.strictEqual(err.code, 'EEXIST'); + w.destroy(); + w.on('close', common.mustCall()); + })); + })); }