build(deps): bump poolifier
[poolifier.git] / tests / pools / thread / fixed.test.mjs
index a1cb8dd294b100263e0bb97e898b2890e02d4c43..fc68fdb23a01a163e33d532d0dd8a1a27b1781ea 100644 (file)
@@ -9,14 +9,14 @@ describe('Fixed thread pool test suite', () => {
   const tasksConcurrency = 2
   const pool = new FixedThreadPool(
     numberOfThreads,
-    './tests/worker-files/thread/testWorker.js',
+    './tests/worker-files/thread/testWorker.mjs',
     {
       errorHandler: e => console.error(e)
     }
   )
   const queuePool = new FixedThreadPool(
     numberOfThreads,
-    './tests/worker-files/thread/testWorker.js',
+    './tests/worker-files/thread/testWorker.mjs',
     {
       enableTasksQueue: true,
       tasksQueueOptions: {
@@ -27,30 +27,30 @@ describe('Fixed thread pool test suite', () => {
   )
   const emptyPool = new FixedThreadPool(
     numberOfThreads,
-    './tests/worker-files/thread/emptyWorker.js',
+    './tests/worker-files/thread/emptyWorker.mjs',
     { exitHandler: () => console.info('empty pool worker exited') }
   )
   const echoPool = new FixedThreadPool(
     numberOfThreads,
-    './tests/worker-files/thread/echoWorker.js'
+    './tests/worker-files/thread/echoWorker.mjs'
   )
   const errorPool = new FixedThreadPool(
     numberOfThreads,
-    './tests/worker-files/thread/errorWorker.js',
+    './tests/worker-files/thread/errorWorker.mjs',
     {
       errorHandler: e => console.error(e)
     }
   )
   const asyncErrorPool = new FixedThreadPool(
     numberOfThreads,
-    './tests/worker-files/thread/asyncErrorWorker.js',
+    './tests/worker-files/thread/asyncErrorWorker.mjs',
     {
       errorHandler: e => console.error(e)
     }
   )
   const asyncPool = new FixedThreadPool(
     numberOfThreads,
-    './tests/worker-files/thread/asyncWorker.js'
+    './tests/worker-files/thread/asyncWorker.mjs'
   )
 
   after('Destroy all pools', async () => {
@@ -82,7 +82,7 @@ describe('Fixed thread pool test suite', () => {
   it("Verify that 'ready' event is emitted", async () => {
     const pool = new FixedThreadPool(
       numberOfThreads,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       {
         errorHandler: e => console.error(e)
       }
@@ -202,8 +202,9 @@ describe('Fixed thread pool test suite', () => {
       error = e
     }
     expect(result).toStrictEqual({ ok: 1 })
-    expect(error).toStrictEqual(
-      new TypeError('Found invalid object in transferList')
+    expect(error).toBeInstanceOf(Error)
+    expect(error.message).toMatch(
+      /Found invalid (object|value) in transferList/
     )
   })
 
@@ -298,7 +299,7 @@ describe('Fixed thread pool test suite', () => {
   })
 
   it('Verify that thread pool options are checked', async () => {
-    const workerFilePath = './tests/worker-files/thread/testWorker.js'
+    const workerFilePath = './tests/worker-files/thread/testWorker.mjs'
     let pool = new FixedThreadPool(numberOfThreads, workerFilePath)
     expect(pool.opts.workerOptions).toBeUndefined()
     await pool.destroy()
@@ -316,7 +317,7 @@ describe('Fixed thread pool test suite', () => {
   })
 
   it('Should work even without opts in input', async () => {
-    const workerFilePath = './tests/worker-files/thread/testWorker.js'
+    const workerFilePath = './tests/worker-files/thread/testWorker.mjs'
     const pool = new FixedThreadPool(numberOfThreads, workerFilePath)
     const res = await pool.execute()
     expect(res).toStrictEqual({ ok: 1 })
@@ -325,7 +326,7 @@ describe('Fixed thread pool test suite', () => {
   })
 
   it('Verify destroyWorkerNode()', async () => {
-    const workerFilePath = './tests/worker-files/thread/testWorker.js'
+    const workerFilePath = './tests/worker-files/thread/testWorker.mjs'
     const pool = new FixedThreadPool(numberOfThreads, workerFilePath)
     const workerNodeKey = 0
     let exitEvent = 0
@@ -338,9 +339,9 @@ describe('Fixed thread pool test suite', () => {
     await pool.destroy()
   })
 
-  it('Verify that a pool with zero worker fails', async () => {
+  it('Verify that a pool with zero worker fails', () => {
     expect(
-      () => new FixedThreadPool(0, './tests/worker-files/thread/testWorker.js')
-    ).toThrowError('Cannot instantiate a fixed pool with zero worker')
+      () => new FixedThreadPool(0, './tests/worker-files/thread/testWorker.mjs')
+    ).toThrow('Cannot instantiate a fixed pool with zero worker')
   })
 })