Bump mocha from 8.3.0 to 8.3.1 (#254)
[poolifier.git] / tests / test-utils.js
CommitLineData
85a3f8a7
APA
1class TestUtils {
2 static async waitExits (pool, numberOfExitEventsToWait) {
3 let exitEvents = 0
4 return new Promise(function (resolve, reject) {
5 pool.workers.forEach(w => {
6 w.on('exit', () => {
7 exitEvents++
8 if (exitEvents === numberOfExitEventsToWait) {
9 resolve(exitEvents)
10 }
11 })
12 })
13 })
14 }
15
16 static async sleep (ms) {
17 return new Promise(resolve => setTimeout(resolve, ms))
18 }
19}
20
21module.exports = TestUtils