test: switch thread worker to ESM
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 29 Sep 2023 22:46:14 +0000 (00:46 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 29 Sep 2023 22:46:14 +0000 (00:46 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
23 files changed:
tests/pools/abstract-pool.test.mjs
tests/pools/selection-strategies/selection-strategies.test.mjs
tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.mjs
tests/pools/selection-strategies/worker-choice-strategy-context.test.mjs
tests/pools/thread/dynamic.test.mjs
tests/pools/thread/fixed.test.mjs
tests/pools/worker-node.test.mjs
tests/utils.test.mjs
tests/worker-files/thread/asyncErrorWorker.mjs [moved from tests/worker-files/thread/asyncErrorWorker.js with 51% similarity]
tests/worker-files/thread/asyncWorker.js [deleted file]
tests/worker-files/thread/asyncWorker.mjs [new file with mode: 0644]
tests/worker-files/thread/echoWorker.js [deleted file]
tests/worker-files/thread/echoWorker.mjs [new file with mode: 0644]
tests/worker-files/thread/emptyWorker.js [deleted file]
tests/worker-files/thread/emptyWorker.mjs [new file with mode: 0644]
tests/worker-files/thread/errorWorker.mjs [moved from tests/worker-files/thread/errorWorker.js with 53% similarity]
tests/worker-files/thread/longRunningWorkerHardBehavior.js [deleted file]
tests/worker-files/thread/longRunningWorkerHardBehavior.mjs [new file with mode: 0644]
tests/worker-files/thread/longRunningWorkerSoftBehavior.js [deleted file]
tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs [new file with mode: 0644]
tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs [moved from tests/worker-files/thread/testMultipleTaskFunctionsWorker.js with 56% similarity]
tests/worker-files/thread/testWorker.js [deleted file]
tests/worker-files/thread/testWorker.mjs [new file with mode: 0644]

index 09a21c9d1fb3a57fb654c5f29c44adf703c025ba..84212a3f4f81f953fe50a718cac4f5f0edba1cdf 100644 (file)
@@ -36,7 +36,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new StubPoolWithIsMain(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             errorHandler: e => console.error(e)
           }
@@ -51,7 +51,7 @@ describe('Abstract pool test suite', () => {
   it('Verify that pool statuses properties are set', async () => {
     const pool = new FixedThreadPool(
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(pool.starting).toBe(false)
     expect(pool.started).toBe(true)
@@ -84,7 +84,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           undefined,
-          './tests/worker-files/thread/testWorker.js'
+          './tests/worker-files/thread/testWorker.mjs'
         )
     ).toThrowError(
       new Error(
@@ -107,7 +107,7 @@ describe('Abstract pool test suite', () => {
   it('Verify that a non integer number of workers is checked', () => {
     expect(
       () =>
-        new FixedThreadPool(0.25, './tests/worker-files/thread/testWorker.js')
+        new FixedThreadPool(0.25, './tests/worker-files/thread/testWorker.mjs')
     ).toThrowError(
       new TypeError(
         'Cannot instantiate a pool with a non safe integer number of workers'
@@ -133,7 +133,7 @@ describe('Abstract pool test suite', () => {
         new DynamicThreadPool(
           0.5,
           1,
-          './tests/worker-files/thread/testWorker.js'
+          './tests/worker-files/thread/testWorker.mjs'
         )
     ).toThrowError(
       new TypeError(
@@ -154,7 +154,11 @@ describe('Abstract pool test suite', () => {
     )
     expect(
       () =>
-        new DynamicThreadPool(2, 1, './tests/worker-files/thread/testWorker.js')
+        new DynamicThreadPool(
+          2,
+          1,
+          './tests/worker-files/thread/testWorker.mjs'
+        )
     ).toThrowError(
       new RangeError(
         'Cannot instantiate a dynamic pool with a maximum pool size inferior to the minimum pool size'
@@ -162,7 +166,11 @@ describe('Abstract pool test suite', () => {
     )
     expect(
       () =>
-        new DynamicThreadPool(0, 0, './tests/worker-files/thread/testWorker.js')
+        new DynamicThreadPool(
+          0,
+          0,
+          './tests/worker-files/thread/testWorker.mjs'
+        )
     ).toThrowError(
       new RangeError(
         'Cannot instantiate a dynamic pool with a maximum pool size equal to zero'
@@ -185,7 +193,7 @@ describe('Abstract pool test suite', () => {
   it('Verify that pool options are checked', async () => {
     let pool = new FixedThreadPool(
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(pool.emitter).toBeInstanceOf(EventEmitterAsyncResource)
     expect(pool.opts).toStrictEqual({
@@ -220,7 +228,7 @@ describe('Abstract pool test suite', () => {
     const testHandler = () => console.info('test handler executed')
     pool = new FixedThreadPool(
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       {
         workerChoiceStrategy: WorkerChoiceStrategies.LEAST_USED,
         workerChoiceStrategyOptions: {
@@ -287,7 +295,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             workerChoiceStrategy: 'invalidStrategy'
           }
@@ -299,7 +307,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             workerChoiceStrategyOptions: {
               retries: 'invalidChoiceRetries'
@@ -315,7 +323,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             workerChoiceStrategyOptions: {
               retries: -1
@@ -331,7 +339,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             workerChoiceStrategyOptions: { weights: {} }
           }
@@ -345,7 +353,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             workerChoiceStrategyOptions: { measurement: 'invalidMeasurement' }
           }
@@ -359,7 +367,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             enableTasksQueue: true,
             tasksQueueOptions: 'invalidTasksQueueOptions'
@@ -372,7 +380,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             enableTasksQueue: true,
             tasksQueueOptions: { concurrency: 0 }
@@ -387,7 +395,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             enableTasksQueue: true,
             tasksQueueOptions: { concurrency: -1 }
@@ -402,7 +410,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             enableTasksQueue: true,
             tasksQueueOptions: { concurrency: 0.2 }
@@ -415,7 +423,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             enableTasksQueue: true,
             tasksQueueOptions: { size: 0 }
@@ -430,7 +438,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             enableTasksQueue: true,
             tasksQueueOptions: { size: -1 }
@@ -445,7 +453,7 @@ describe('Abstract pool test suite', () => {
       () =>
         new FixedThreadPool(
           numberOfWorkers,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           {
             enableTasksQueue: true,
             tasksQueueOptions: { size: 0.2 }
@@ -459,7 +467,7 @@ describe('Abstract pool test suite', () => {
   it('Verify that pool worker choice strategy options can be set', async () => {
     const pool = new FixedThreadPool(
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
     )
     expect(pool.opts.workerChoiceStrategyOptions).toStrictEqual({
@@ -633,7 +641,7 @@ describe('Abstract pool test suite', () => {
   it('Verify that pool tasks queue can be enabled/disabled', async () => {
     const pool = new FixedThreadPool(
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(pool.opts.enableTasksQueue).toBe(false)
     expect(pool.opts.tasksQueueOptions).toBeUndefined()
@@ -678,7 +686,7 @@ describe('Abstract pool test suite', () => {
   it('Verify that pool tasks queue options can be set', async () => {
     const pool = new FixedThreadPool(
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { enableTasksQueue: true }
     )
     expect(pool.opts.tasksQueueOptions).toStrictEqual({
@@ -768,7 +776,7 @@ describe('Abstract pool test suite', () => {
   it('Verify that pool info is set', async () => {
     let pool = new FixedThreadPool(
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(pool.info).toStrictEqual({
       version,
@@ -861,7 +869,7 @@ describe('Abstract pool test suite', () => {
     pool = new DynamicThreadPool(
       Math.floor(numberOfWorkers / 2),
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     for (const workerNode of pool.workerNodes) {
       expect(workerNode).toBeInstanceOf(WorkerNode)
@@ -890,7 +898,7 @@ describe('Abstract pool test suite', () => {
     pool = new DynamicThreadPool(
       Math.floor(numberOfWorkers / 2),
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     for (const workerNode of pool.workerNodes) {
       expect(workerNode).toBeInstanceOf(WorkerNode)
@@ -1021,7 +1029,7 @@ describe('Abstract pool test suite', () => {
     const pool = new DynamicThreadPool(
       Math.floor(numberOfWorkers / 2),
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     const promises = new Set()
     const maxMultiplier = 2
@@ -1135,7 +1143,7 @@ describe('Abstract pool test suite', () => {
   it("Verify that pool event emitter 'busy' event can register a callback", async () => {
     const pool = new FixedThreadPool(
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(pool.emitter.eventNames()).toStrictEqual([])
     const promises = new Set()
@@ -1176,7 +1184,7 @@ describe('Abstract pool test suite', () => {
     const pool = new DynamicThreadPool(
       Math.floor(numberOfWorkers / 2),
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(pool.emitter.eventNames()).toStrictEqual([])
     const promises = new Set()
@@ -1214,7 +1222,7 @@ describe('Abstract pool test suite', () => {
   it("Verify that pool event emitter 'backPressure' event can register a callback", async () => {
     const pool = new FixedThreadPool(
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       {
         enableTasksQueue: true
       }
@@ -1262,7 +1270,7 @@ describe('Abstract pool test suite', () => {
     const dynamicThreadPool = new DynamicThreadPool(
       Math.floor(numberOfWorkers / 2),
       numberOfWorkers,
-      './tests/worker-files/thread/testMultipleTaskFunctionsWorker.js'
+      './tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs'
     )
     await waitPoolEvents(dynamicThreadPool, PoolEvents.ready, 1)
     expect(dynamicThreadPool.hasTaskFunction(DEFAULT_TASK_NAME)).toBe(true)
@@ -1292,7 +1300,7 @@ describe('Abstract pool test suite', () => {
     const dynamicThreadPool = new DynamicThreadPool(
       Math.floor(numberOfWorkers / 2),
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     await waitPoolEvents(dynamicThreadPool, PoolEvents.ready, 1)
     await expect(
@@ -1363,7 +1371,7 @@ describe('Abstract pool test suite', () => {
     const dynamicThreadPool = new DynamicThreadPool(
       Math.floor(numberOfWorkers / 2),
       numberOfWorkers,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     await waitPoolEvents(dynamicThreadPool, PoolEvents.ready, 1)
     expect(dynamicThreadPool.listTaskFunctionNames()).toStrictEqual([
@@ -1404,7 +1412,7 @@ describe('Abstract pool test suite', () => {
     const dynamicThreadPool = new DynamicThreadPool(
       Math.floor(numberOfWorkers / 2),
       numberOfWorkers,
-      './tests/worker-files/thread/testMultipleTaskFunctionsWorker.js'
+      './tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs'
     )
     await waitPoolEvents(dynamicThreadPool, PoolEvents.ready, 1)
     expect(dynamicThreadPool.listTaskFunctionNames()).toStrictEqual([
@@ -1432,7 +1440,7 @@ describe('Abstract pool test suite', () => {
     const dynamicThreadPool = new DynamicThreadPool(
       Math.floor(numberOfWorkers / 2),
       numberOfWorkers,
-      './tests/worker-files/thread/testMultipleTaskFunctionsWorker.js'
+      './tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs'
     )
     await waitPoolEvents(dynamicThreadPool, PoolEvents.ready, 1)
     await expect(
index 342d2fa6c997c0bfe1f696cfcecfefcce91931c2..e0eec68b714a3152e49ed6bfd3e26d50a06e8584 100644 (file)
@@ -30,7 +30,7 @@ describe('Selection strategies test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(pool.opts.workerChoiceStrategy).toBe(
       WorkerChoiceStrategies.ROUND_ROBIN
@@ -43,7 +43,7 @@ describe('Selection strategies test suite', () => {
     for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
       const pool = new FixedThreadPool(
         max,
-        './tests/worker-files/thread/testWorker.js',
+        './tests/worker-files/thread/testWorker.mjs',
         { workerChoiceStrategy }
       )
       expect(pool.opts.workerChoiceStrategy).toBe(workerChoiceStrategy)
@@ -59,7 +59,7 @@ describe('Selection strategies test suite', () => {
       const pool = new DynamicThreadPool(
         min,
         max,
-        './tests/worker-files/thread/testWorker.js'
+        './tests/worker-files/thread/testWorker.mjs'
       )
       pool.setWorkerChoiceStrategy(workerChoiceStrategy)
       expect(pool.opts.workerChoiceStrategy).toBe(workerChoiceStrategy)
@@ -110,7 +110,7 @@ describe('Selection strategies test suite', () => {
   it('Verify available strategies default internals at pool creation', async () => {
     const pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     for (const workerChoiceStrategy of Object.values(WorkerChoiceStrategies)) {
       expect(
@@ -178,7 +178,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -189,7 +189,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -204,7 +204,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -230,7 +230,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -260,7 +260,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
     const pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     // TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose`
@@ -315,7 +315,7 @@ describe('Selection strategies test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     // TODO: Create a better test to cover `RoundRobinWorkerChoiceStrategy#choose`
@@ -384,7 +384,7 @@ describe('Selection strategies test suite', () => {
     await pool.destroy()
     pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     results = new Set()
@@ -399,7 +399,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.ROUND_ROBIN
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
     )
     expect(
@@ -427,7 +427,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
     )
     expect(
@@ -459,7 +459,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_USED
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -470,7 +470,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -485,7 +485,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_USED
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -511,7 +511,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -540,7 +540,7 @@ describe('Selection strategies test suite', () => {
   it('Verify LEAST_USED strategy can be run in a fixed pool', async () => {
     const pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.LEAST_USED }
     )
     // TODO: Create a better test to cover `LeastUsedWorkerChoiceStrategy#choose`
@@ -598,7 +598,7 @@ describe('Selection strategies test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.LEAST_USED }
     )
     // TODO: Create a better test to cover `LeastUsedWorkerChoiceStrategy#choose`
@@ -656,7 +656,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_BUSY
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -667,7 +667,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -682,7 +682,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_BUSY
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -708,7 +708,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -737,7 +737,7 @@ describe('Selection strategies test suite', () => {
   it('Verify LEAST_BUSY strategy can be run in a fixed pool', async () => {
     const pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.LEAST_BUSY }
     )
     // TODO: Create a better test to cover `LeastBusyWorkerChoiceStrategy#choose`
@@ -805,7 +805,7 @@ describe('Selection strategies test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.LEAST_BUSY }
     )
     // TODO: Create a better test to cover `LeastBusyWorkerChoiceStrategy#choose`
@@ -873,7 +873,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_ELU
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -884,7 +884,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -899,7 +899,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.LEAST_ELU
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -925,7 +925,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -954,7 +954,7 @@ describe('Selection strategies test suite', () => {
   it('Verify LEAST_ELU strategy can be run in a fixed pool', async () => {
     const pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.LEAST_ELU }
     )
     // TODO: Create a better test to cover `LeastEluWorkerChoiceStrategy#choose`
@@ -1028,7 +1028,7 @@ describe('Selection strategies test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.LEAST_ELU }
     )
     // TODO: Create a better test to cover `LeastEluWorkerChoiceStrategy#choose`
@@ -1102,7 +1102,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -1113,7 +1113,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -1128,7 +1128,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -1154,7 +1154,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -1183,7 +1183,7 @@ describe('Selection strategies test suite', () => {
   it('Verify FAIR_SHARE strategy can be run in a fixed pool', async () => {
     const pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
     )
     // TODO: Create a better test to cover `FairShareChoiceStrategy#choose`
@@ -1268,7 +1268,7 @@ describe('Selection strategies test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE }
     )
     // TODO: Create a better test to cover `FairShareChoiceStrategy#choose`
@@ -1353,7 +1353,7 @@ describe('Selection strategies test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       {
         workerChoiceStrategy: WorkerChoiceStrategies.FAIR_SHARE,
         workerChoiceStrategyOptions: {
@@ -1443,7 +1443,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.FAIR_SHARE
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     for (const workerNode of pool.workerNodes) {
       workerNode.strategyData = {
@@ -1458,7 +1458,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     for (const workerNode of pool.workerNodes) {
       workerNode.strategyData = {
@@ -1477,7 +1477,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -1488,7 +1488,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -1503,7 +1503,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -1529,7 +1529,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -1558,7 +1558,7 @@ describe('Selection strategies test suite', () => {
   it('Verify WEIGHTED_ROUND_ROBIN strategy can be run in a fixed pool', async () => {
     const pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
     )
     // TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose`
@@ -1636,7 +1636,7 @@ describe('Selection strategies test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN }
     )
     // TODO: Create a better test to cover `WeightedRoundRobinWorkerChoiceStrategy#choose`
@@ -1714,7 +1714,7 @@ describe('Selection strategies test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       {
         workerChoiceStrategy: WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN,
         workerChoiceStrategyOptions: {
@@ -1797,7 +1797,7 @@ describe('Selection strategies test suite', () => {
     const workerChoiceStrategy = WorkerChoiceStrategies.WEIGHTED_ROUND_ROBIN
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1844,7 +1844,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -1896,7 +1896,7 @@ describe('Selection strategies test suite', () => {
       WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -1907,7 +1907,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(pool.workerChoiceStrategyContext.getStrategyPolicy()).toStrictEqual({
@@ -1923,7 +1923,7 @@ describe('Selection strategies test suite', () => {
       WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -1949,7 +1949,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       { workerChoiceStrategy }
     )
     expect(
@@ -1978,7 +1978,7 @@ describe('Selection strategies test suite', () => {
   it('Verify INTERLEAVED_WEIGHTED_ROUND_ROBIN strategy can be run in a fixed pool', async () => {
     const pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       {
         workerChoiceStrategy:
           WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
@@ -2063,7 +2063,7 @@ describe('Selection strategies test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js',
+      './tests/worker-files/thread/testWorker.mjs',
       {
         workerChoiceStrategy:
           WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
@@ -2149,7 +2149,7 @@ describe('Selection strategies test suite', () => {
       WorkerChoiceStrategies.INTERLEAVED_WEIGHTED_ROUND_ROBIN
     let pool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -2220,7 +2220,7 @@ describe('Selection strategies test suite', () => {
     pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(
       pool.workerChoiceStrategyContext.workerChoiceStrategies.get(
@@ -2297,7 +2297,7 @@ describe('Selection strategies test suite', () => {
         new DynamicThreadPool(
           min,
           max,
-          './tests/worker-files/thread/testWorker.js',
+          './tests/worker-files/thread/testWorker.mjs',
           { workerChoiceStrategy: 'UNKNOWN_STRATEGY' }
         )
     ).toThrowError("Invalid worker choice strategy 'UNKNOWN_STRATEGY'")
index c659b31e7bcc2dec1db31a0a7554b1b82cb6c549..a8c4bdd5eaabf9f0845e82d00d9a1bd9c2c2caa1 100644 (file)
@@ -10,7 +10,10 @@ describe('Weighted round robin strategy worker choice strategy test suite', () =
   let pool
 
   before(() => {
-    pool = new FixedThreadPool(max, './tests/worker-files/thread/testWorker.js')
+    pool = new FixedThreadPool(
+      max,
+      './tests/worker-files/thread/testWorker.mjs'
+    )
   })
 
   afterEach(() => {
index f9b1c8d590ac39e9d8657bc9348456483808af0a..e95911db8d6cfb18da375bc2f18a44321e1e6685 100644 (file)
@@ -22,12 +22,12 @@ describe('Worker choice strategy context test suite', () => {
   before(() => {
     fixedPool = new FixedThreadPool(
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     dynamicPool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
   })
 
index 0a608a01f2d9d478b9fc4a17c388bcb1ac89b4dd..0918065b403314f942fc4e3422e83740cdd3e654 100644 (file)
@@ -9,7 +9,7 @@ describe('Dynamic thread pool test suite', () => {
   const pool = new DynamicThreadPool(
     min,
     max,
-    './tests/worker-files/thread/testWorker.js',
+    './tests/worker-files/thread/testWorker.mjs',
     {
       errorHandler: e => console.error(e)
     }
@@ -82,7 +82,7 @@ describe('Dynamic thread pool test suite', () => {
     const pool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     const res = await pool.execute()
     expect(res).toStrictEqual({ ok: 1 })
@@ -94,7 +94,7 @@ describe('Dynamic thread pool test suite', () => {
     const longRunningPool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/longRunningWorkerHardBehavior.js',
+      './tests/worker-files/thread/longRunningWorkerHardBehavior.mjs',
       {
         errorHandler: e => console.error(e),
         onlineHandler: () => console.info('long executing worker is online'),
@@ -121,7 +121,7 @@ describe('Dynamic thread pool test suite', () => {
     const longRunningPool = new DynamicThreadPool(
       min,
       max,
-      './tests/worker-files/thread/longRunningWorkerSoftBehavior.js',
+      './tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs',
       {
         errorHandler: e => console.error(e),
         onlineHandler: () => console.info('long executing worker is online'),
@@ -144,7 +144,7 @@ describe('Dynamic thread pool test suite', () => {
     const pool = new DynamicThreadPool(
       0,
       max,
-      './tests/worker-files/thread/testWorker.js'
+      './tests/worker-files/thread/testWorker.mjs'
     )
     expect(pool).toBeInstanceOf(DynamicThreadPool)
     // We need to clean up the resources after our test
index a1cb8dd294b100263e0bb97e898b2890e02d4c43..3969c83ad7464c728d7df33dd092673c16384734 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)
       }
@@ -298,7 +298,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 +316,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 +325,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
@@ -340,7 +340,7 @@ describe('Fixed thread pool test suite', () => {
 
   it('Verify that a pool with zero worker fails', async () => {
     expect(
-      () => new FixedThreadPool(0, './tests/worker-files/thread/testWorker.js')
+      () => new FixedThreadPool(0, './tests/worker-files/thread/testWorker.mjs')
     ).toThrowError('Cannot instantiate a fixed pool with zero worker')
   })
 })
index 0780db255d618cf913b782a8e1e957613d139d8e..a847e4fedec5374713f514900beed3afb8097e67 100644 (file)
@@ -8,7 +8,7 @@ import { Deque } from '../../lib/deque.js'
 import { DEFAULT_TASK_NAME } from '../../lib/utils.js'
 
 describe('Worker node test suite', () => {
-  const threadWorker = new Worker('./tests/worker-files/thread/testWorker.js')
+  const threadWorker = new Worker('./tests/worker-files/thread/testWorker.mjs')
   const clusterWorker = cluster.fork()
   const threadWorkerNode = new WorkerNode(threadWorker, 12)
   const clusterWorkerNode = new WorkerNode(clusterWorker, 12)
index 74c53a1629b7f3ef7738bdbc50e3f908216457dd..c048141bf2ffcd7aab57de5d9b7aaa178d630137 100644 (file)
@@ -66,13 +66,15 @@ describe('Utils test suite', () => {
 
   it('Verify getWorkerType() behavior', () => {
     expect(
-      getWorkerType(new Worker('./tests/worker-files/thread/testWorker.js'))
+      getWorkerType(new Worker('./tests/worker-files/thread/testWorker.mjs'))
     ).toBe(WorkerTypes.thread)
     expect(getWorkerType(cluster.fork())).toBe(WorkerTypes.cluster)
   })
 
   it('Verify getWorkerId() behavior', () => {
-    const threadWorker = new Worker('./tests/worker-files/thread/testWorker.js')
+    const threadWorker = new Worker(
+      './tests/worker-files/thread/testWorker.mjs'
+    )
     const clusterWorker = cluster.fork()
     expect(getWorkerId(threadWorker)).toBe(threadWorker.threadId)
     expect(getWorkerId(clusterWorker)).toBe(clusterWorker.id)
similarity index 51%
rename from tests/worker-files/thread/asyncErrorWorker.js
rename to tests/worker-files/thread/asyncErrorWorker.mjs
index f696b101947d6dc7ed180feae6fe7a0f763797b6..ff16bb6a87251d7e7315580eb620d478d018d943 100644 (file)
@@ -1,7 +1,10 @@
-'use strict'
-const { ThreadWorker, KillBehaviors } = require('../../../lib')
-const { sleepTaskFunction } = require('../../test-utils')
+import { KillBehaviors, ThreadWorker } from '../../../lib/index.js'
+import { sleepTaskFunction } from '../../test-utils.js'
 
+/**
+ *
+ * @param data
+ */
 async function error (data) {
   return sleepTaskFunction(
     data,
@@ -11,7 +14,7 @@ async function error (data) {
   )
 }
 
-module.exports = new ThreadWorker(error, {
+export default new ThreadWorker(error, {
   killBehavior: KillBehaviors.HARD,
   maxInactiveTime: 500
 })
diff --git a/tests/worker-files/thread/asyncWorker.js b/tests/worker-files/thread/asyncWorker.js
deleted file mode 100644 (file)
index c3bcdc8..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict'
-const { ThreadWorker, KillBehaviors } = require('../../../lib')
-const { sleepTaskFunction } = require('../../test-utils')
-
-async function sleep (data) {
-  return sleepTaskFunction(data, 2000)
-}
-
-module.exports = new ThreadWorker(sleep, {
-  killBehavior: KillBehaviors.HARD,
-  maxInactiveTime: 500
-})
diff --git a/tests/worker-files/thread/asyncWorker.mjs b/tests/worker-files/thread/asyncWorker.mjs
new file mode 100644 (file)
index 0000000..4c52783
--- /dev/null
@@ -0,0 +1,15 @@
+import { KillBehaviors, ThreadWorker } from '../../../lib/index.js'
+import { sleepTaskFunction } from '../../test-utils.js'
+
+/**
+ *
+ * @param data
+ */
+async function sleep (data) {
+  return sleepTaskFunction(data, 2000)
+}
+
+export default new ThreadWorker(sleep, {
+  killBehavior: KillBehaviors.HARD,
+  maxInactiveTime: 500
+})
diff --git a/tests/worker-files/thread/echoWorker.js b/tests/worker-files/thread/echoWorker.js
deleted file mode 100644 (file)
index 998e56b..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-'use strict'
-const { ThreadWorker, KillBehaviors } = require('../../../lib')
-
-function echo (data) {
-  return data
-}
-
-module.exports = new ThreadWorker(echo, {
-  killBehavior: KillBehaviors.HARD
-})
diff --git a/tests/worker-files/thread/echoWorker.mjs b/tests/worker-files/thread/echoWorker.mjs
new file mode 100644 (file)
index 0000000..0b9251c
--- /dev/null
@@ -0,0 +1,13 @@
+import { KillBehaviors, ThreadWorker } from '../../../lib/index.js'
+
+/**
+ *
+ * @param data
+ */
+function echo (data) {
+  return data
+}
+
+export default new ThreadWorker(echo, {
+  killBehavior: KillBehaviors.HARD
+})
diff --git a/tests/worker-files/thread/emptyWorker.js b/tests/worker-files/thread/emptyWorker.js
deleted file mode 100644 (file)
index d77b472..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-'use strict'
-const { ThreadWorker, KillBehaviors } = require('../../../lib')
-
-function test () {}
-
-module.exports = new ThreadWorker(test, {
-  killBehavior: KillBehaviors.HARD,
-  maxInactiveTime: 500
-})
diff --git a/tests/worker-files/thread/emptyWorker.mjs b/tests/worker-files/thread/emptyWorker.mjs
new file mode 100644 (file)
index 0000000..b129244
--- /dev/null
@@ -0,0 +1,11 @@
+import { KillBehaviors, ThreadWorker } from '../../../lib/index.js'
+
+/**
+ *
+ */
+function test () {}
+
+export default new ThreadWorker(test, {
+  killBehavior: KillBehaviors.HARD,
+  maxInactiveTime: 500
+})
similarity index 53%
rename from tests/worker-files/thread/errorWorker.js
rename to tests/worker-files/thread/errorWorker.mjs
index e5738982e9c40ee9f17ea83424ef91d9a01cba8a..101e45585ba49afb59ce9a7c0f6f983bd1bf153f 100644 (file)
@@ -1,11 +1,13 @@
-'use strict'
-const { ThreadWorker, KillBehaviors } = require('../../../lib')
+import { KillBehaviors, ThreadWorker } from '../../../lib/index.js'
 
+/**
+ *
+ */
 function error () {
   throw new Error('Error Message from ThreadWorker')
 }
 
-module.exports = new ThreadWorker(error, {
+export default new ThreadWorker(error, {
   killBehavior: KillBehaviors.HARD,
   maxInactiveTime: 500
 })
diff --git a/tests/worker-files/thread/longRunningWorkerHardBehavior.js b/tests/worker-files/thread/longRunningWorkerHardBehavior.js
deleted file mode 100644 (file)
index e7d84df..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-'use strict'
-const { ThreadWorker, KillBehaviors } = require('../../../lib')
-const { sleepTaskFunction } = require('../../test-utils')
-
-async function sleep (data) {
-  return sleepTaskFunction(data, 50000)
-}
-
-module.exports = new ThreadWorker(sleep, {
-  killBehavior: KillBehaviors.HARD,
-  maxInactiveTime: 500
-})
diff --git a/tests/worker-files/thread/longRunningWorkerHardBehavior.mjs b/tests/worker-files/thread/longRunningWorkerHardBehavior.mjs
new file mode 100644 (file)
index 0000000..911ddb9
--- /dev/null
@@ -0,0 +1,15 @@
+import { KillBehaviors, ThreadWorker } from '../../../lib/index.js'
+import { sleepTaskFunction } from '../../test-utils.js'
+
+/**
+ *
+ * @param data
+ */
+async function sleep (data) {
+  return sleepTaskFunction(data, 50000)
+}
+
+export default new ThreadWorker(sleep, {
+  killBehavior: KillBehaviors.HARD,
+  maxInactiveTime: 500
+})
diff --git a/tests/worker-files/thread/longRunningWorkerSoftBehavior.js b/tests/worker-files/thread/longRunningWorkerSoftBehavior.js
deleted file mode 100644 (file)
index 3b90236..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-'use strict'
-const { ThreadWorker } = require('../../../lib')
-const { sleepTaskFunction } = require('../../test-utils')
-
-async function sleep (data) {
-  return sleepTaskFunction(data, 50000)
-}
-
-module.exports = new ThreadWorker(sleep, {
-  maxInactiveTime: 500
-})
diff --git a/tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs b/tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs
new file mode 100644 (file)
index 0000000..6441a18
--- /dev/null
@@ -0,0 +1,14 @@
+import { ThreadWorker } from '../../../lib/index.js'
+import { sleepTaskFunction } from '../../test-utils.js'
+
+/**
+ *
+ * @param data
+ */
+async function sleep (data) {
+  return sleepTaskFunction(data, 50000)
+}
+
+export default new ThreadWorker(sleep, {
+  maxInactiveTime: 500
+})
similarity index 56%
rename from tests/worker-files/thread/testMultipleTaskFunctionsWorker.js
rename to tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs
index 3fb6d758731c4c5418b50cb15def620ede97eb53..d559beb7e03baa53c14319fca7b4613b37c09cc6 100644 (file)
@@ -1,12 +1,11 @@
-'use strict'
-const { ThreadWorker, KillBehaviors } = require('../../../lib')
-const {
-  jsonIntegerSerialization,
+import { KillBehaviors, ThreadWorker } from '../../../lib/index.js'
+import {
   factorial,
-  fibonacci
-} = require('../../test-utils')
+  fibonacci,
+  jsonIntegerSerialization
+} from '../../test-utils.js'
 
-module.exports = new ThreadWorker(
+export default new ThreadWorker(
   {
     jsonIntegerSerialization: data => jsonIntegerSerialization(data.n),
     factorial: data => factorial(data.n),
diff --git a/tests/worker-files/thread/testWorker.js b/tests/worker-files/thread/testWorker.js
deleted file mode 100644 (file)
index 3945589..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-'use strict'
-const { ThreadWorker, KillBehaviors } = require('../../../lib')
-const { executeTaskFunction } = require('../../test-utils')
-const { TaskFunctions } = require('../../test-types')
-
-function test (data) {
-  data = data || {}
-  data.function = data.function || TaskFunctions.jsonIntegerSerialization
-  return executeTaskFunction(data)
-}
-
-module.exports = new ThreadWorker(test, {
-  killBehavior: KillBehaviors.HARD,
-  maxInactiveTime: 500
-})
diff --git a/tests/worker-files/thread/testWorker.mjs b/tests/worker-files/thread/testWorker.mjs
new file mode 100644 (file)
index 0000000..e2c6706
--- /dev/null
@@ -0,0 +1,18 @@
+import { KillBehaviors, ThreadWorker } from '../../../lib/index.js'
+import { executeTaskFunction } from '../../test-utils.js'
+import { TaskFunctions } from '../../test-types.js'
+
+/**
+ *
+ * @param data
+ */
+function test (data) {
+  data = data || {}
+  data.function = data.function || TaskFunctions.jsonIntegerSerialization
+  return executeTaskFunction(data)
+}
+
+export default new ThreadWorker(test, {
+  killBehavior: KillBehaviors.HARD,
+  maxInactiveTime: 500
+})