From ee4d12176bcd13ca39d490afebb5c495e49d1e23 Mon Sep 17 00:00:00 2001 From: KienHT <71423573+kien-ht@users.noreply.github.com> Date: Tue, 28 May 2024 14:44:16 +0000 Subject: [PATCH] fix: incomplete diff generations --- src/plugin.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugin.js b/src/plugin.js index e64bb00..41775c5 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -110,7 +110,15 @@ const getStatsComparisonAndPopulateDiffIfAny = async (args) => { if (testFailed) { fs.ensureFileSync(paths.image.diff(args.testName)) - diff.pack().pipe(fs.createWriteStream(paths.image.diff(args.testName))) + const stream = diff + .pack() + .pipe(fs.createWriteStream(paths.image.diff(args.testName))) + + // make sure the diff image fully populated before proceeding further + await new Promise((resolve, reject) => { + stream.once('finish', resolve) + stream.once('error', reject) + }) } return { percentage, testFailed }