Skip to content

Commit

Permalink
try making tests less flaky
Browse files Browse the repository at this point in the history
  • Loading branch information
rluvaton committed Aug 10, 2023
1 parent d4b2f9a commit 1bcc1e0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions test/never-drain.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ test('emit warning when the worker gracefully exit without the stream ended', as
const stream = new ThreadStream({
filename: join(__dirname, 'to-next.js')
})
stream.unref()

let streamWarning
function saveWarning (e) {
Expand All @@ -36,11 +37,12 @@ test('emit warning when the worker gracefully exit without the stream ended', as
}
process.on('warning', saveWarning)

for (let i = 0; i < 10_000; i++) {
const data = 'hello'.repeat(10)
for (let i = 0; i < 1000; i++) {
if (streamWarning?.message === expectedWarning) {
break
}
stream.write('hello')
stream.write(data)
await new Promise((resolve) => {
setTimeout(resolve, 1)
})
Expand Down

0 comments on commit 1bcc1e0

Please sign in to comment.