X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=tests%2Ftest-utils.js;h=894471697cb42cc408c906021ee28e87147fcfbc;hb=164d950a1bcdc39b4762294c1581e8befbb344e2;hp=f650af789867c1e87d56e963a210a9f4320a02c0;hpb=f821a8411ccb1217a6deb9d2e082eecc4ba6d9b4;p=poolifier.git diff --git a/tests/test-utils.js b/tests/test-utils.js index f650af78..89447169 100644 --- a/tests/test-utils.js +++ b/tests/test-utils.js @@ -4,14 +4,14 @@ class TestUtils { static async waitExits (pool, numberOfExitEventsToWait) { return new Promise(resolve => { let exitEvents = 0 - pool.workers.forEach(w => { - w.on('exit', () => { - exitEvents++ + for (const workerItem of pool.workers) { + workerItem.worker.on('exit', () => { + ++exitEvents if (exitEvents === numberOfExitEventsToWait) { resolve(exitEvents) } }) - }) + } }) } @@ -77,9 +77,8 @@ class TestUtils { static factorial (n) { if (n === 0) { return 1 - } else { - return TestUtils.factorial(n - 1) * n } + return TestUtils.factorial(n - 1) * n } static executeWorkerFunction (data) {