Fix EPIPE when run unit tests (#187)
[poolifier.git] / tests / pools / cluster / dynamic.test.js
index fbeb77cf3555c76ce1a93b53b926cee8f505ce91..2cff475f99cd6b0368b216a9f45931fd7050fed6 100644 (file)
@@ -62,8 +62,10 @@ describe('Dynamic cluster pool test suite ', () => {
       1,
       './tests/worker-files/cluster/testWorker.js'
     )
-    const res = await pool1.execute({ test: 'test' })
-    expect(res).toBeFalsy()
+    const result = await pool1.execute({ test: 'test' })
+    expect(result).toBeFalsy()
+    // We need to clean up the resources after our test
+    await pool1.destroy()
   })
 
   it('Verify scale processes up and down is working when long running task is used:hard', async () => {
@@ -80,6 +82,8 @@ describe('Dynamic cluster pool test suite ', () => {
     await TestUtils.waitExits(longRunningPool, max - min)
     // Here we expect the workers to be at the max size since that the task is still running
     expect(longRunningPool.workers.length).toBe(min)
+    // We need to clean up the resources after our test
+    await longRunningPool.destroy()
   })
 
   it('Verify scale processes up and down is working when long running task is used:soft', async () => {
@@ -96,5 +100,7 @@ describe('Dynamic cluster pool test suite ', () => {
     await TestUtils.sleep(1500)
     // Here we expect the workers to be at the max size since that the task is still running
     expect(longRunningPool.workers.length).toBe(max)
+    // We need to clean up the resources after our test
+    await longRunningPool.destroy()
   })
 })