From 8fde791afd4afd5495321d88c62b3b4c335b7bd4 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Mon, 15 Nov 2021 22:49:02 +0100 Subject: [PATCH] Clarify that `watchFileCreated` fails are timeouts (#1219) --- 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) })