From 2952d7736acbf7ac707b916de9abd93e045940c0 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Mon, 15 Nov 2021 16:57:04 +0100 Subject: [PATCH] Clarify that `watchFileCreated` fails are timeouts Relates to #1215 --- test/helper.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/helper.js b/test/helper.js index f2f468008..e57419f86 100644 --- a/test/helper.js +++ b/test/helper.js @@ -59,15 +59,19 @@ function watchFileCreated (filename) { const threshold = TIMEOUT / INTERVAL let counter = 0 const interval = setInterval(() => { + const exists = existsSync(filename) // On some CI runs file is created but not filled - if (existsSync(filename) && statSync(filename).size !== 0) { + if (exists && statSync(filename).size !== 0) { clearInterval(interval) resolve() } else if (counter <= threshold) { counter++ } else { clearInterval(interval) - reject(new Error(`${filename} was not created.`)) + reject(new Error( + `${filename} hasn't been created within ${TIMEOUT} ms. ` + + (exists ? 'File exist, but still empty.' : 'File not yet created.') + )) } }, INTERVAL) })