Skip to content

Commit

Permalink
Clarify that watchFileCreated fails are timeouts (#1219)
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli committed Nov 15, 2021
1 parent 12d4dce commit 8fde791
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/helper.js
Expand Up @@ -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)
})
Expand Down

0 comments on commit 8fde791

Please sign in to comment.