From: Jérôme Benoit Date: Mon, 23 Feb 2026 11:34:37 +0000 (+0100) Subject: test: use ESM imports in worker threads files X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=55a83023a8406c0aa6fe74e32700f9314e5bdc4b;p=poolifier.git test: use ESM imports in worker threads files Signed-off-by: Jérôme Benoit --- diff --git a/src/pools/utils.ts b/src/pools/utils.ts index 51634ee7a..8961a87d4 100644 --- a/src/pools/utils.ts +++ b/src/pools/utils.ts @@ -1,6 +1,5 @@ import cluster, { Worker as ClusterWorker } from 'node:cluster' import { existsSync } from 'node:fs' -import { env } from 'node:process' import { SHARE_ENV, Worker as ThreadWorker, @@ -364,10 +363,7 @@ const updateMeasurementStatistics = ( } } } -if (env.NODE_ENV === 'test') { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - exports.updateMeasurementStatistics = updateMeasurementStatistics -} +export { updateMeasurementStatistics } export const updateWaitTimeWorkerUsage = < Worker extends IWorker, diff --git a/tests/worker-files/thread/asyncErrorWorker.mjs b/tests/worker-files/thread/asyncErrorWorker.mjs index 917ded48f..9030df157 100644 --- a/tests/worker-files/thread/asyncErrorWorker.mjs +++ b/tests/worker-files/thread/asyncErrorWorker.mjs @@ -1,4 +1,4 @@ -import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' +import { KillBehaviors, ThreadWorker } from '../../../lib/index.mjs' import { sleepTaskFunction } from '../../test-utils.cjs' /** diff --git a/tests/worker-files/thread/asyncWorker.mjs b/tests/worker-files/thread/asyncWorker.mjs index e72e9798d..3e43f744a 100644 --- a/tests/worker-files/thread/asyncWorker.mjs +++ b/tests/worker-files/thread/asyncWorker.mjs @@ -1,4 +1,4 @@ -import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' +import { KillBehaviors, ThreadWorker } from '../../../lib/index.mjs' import { sleepTaskFunction } from '../../test-utils.cjs' /** diff --git a/tests/worker-files/thread/echoWorker.mjs b/tests/worker-files/thread/echoWorker.mjs index 4bee1c2dc..cc1638d55 100644 --- a/tests/worker-files/thread/echoWorker.mjs +++ b/tests/worker-files/thread/echoWorker.mjs @@ -1,4 +1,4 @@ -import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' +import { KillBehaviors, ThreadWorker } from '../../../lib/index.mjs' /** * Test worker function that echoes the input data. diff --git a/tests/worker-files/thread/emptyWorker.mjs b/tests/worker-files/thread/emptyWorker.mjs index 7d37eb95e..8259db1a3 100644 --- a/tests/worker-files/thread/emptyWorker.mjs +++ b/tests/worker-files/thread/emptyWorker.mjs @@ -1,4 +1,4 @@ -import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' +import { KillBehaviors, ThreadWorker } from '../../../lib/index.mjs' /** * diff --git a/tests/worker-files/thread/errorWorker.mjs b/tests/worker-files/thread/errorWorker.mjs index 582d094ea..10fa89337 100644 --- a/tests/worker-files/thread/errorWorker.mjs +++ b/tests/worker-files/thread/errorWorker.mjs @@ -1,4 +1,4 @@ -import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' +import { KillBehaviors, ThreadWorker } from '../../../lib/index.mjs' /** * diff --git a/tests/worker-files/thread/longRunningWorkerHardBehavior.mjs b/tests/worker-files/thread/longRunningWorkerHardBehavior.mjs index 05ffe47a4..374c3f716 100644 --- a/tests/worker-files/thread/longRunningWorkerHardBehavior.mjs +++ b/tests/worker-files/thread/longRunningWorkerHardBehavior.mjs @@ -1,4 +1,4 @@ -import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' +import { KillBehaviors, ThreadWorker } from '../../../lib/index.mjs' import { sleepTaskFunction } from '../../test-utils.cjs' /** diff --git a/tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs b/tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs index 45dc3894b..af960b521 100644 --- a/tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs +++ b/tests/worker-files/thread/longRunningWorkerSoftBehavior.mjs @@ -1,4 +1,4 @@ -import { ThreadWorker } from '../../../lib/index.cjs' +import { ThreadWorker } from '../../../lib/index.mjs' import { sleepTaskFunction } from '../../test-utils.cjs' /** diff --git a/tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs b/tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs index f78d3180a..36c7fc874 100644 --- a/tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs +++ b/tests/worker-files/thread/testMultipleTaskFunctionsWorker.mjs @@ -1,4 +1,4 @@ -import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' +import { KillBehaviors, ThreadWorker } from '../../../lib/index.mjs' import { factorial, fibonacci, diff --git a/tests/worker-files/thread/testTaskFunctionObjectsWorker.mjs b/tests/worker-files/thread/testTaskFunctionObjectsWorker.mjs index 70251dd28..1a3c903a0 100644 --- a/tests/worker-files/thread/testTaskFunctionObjectsWorker.mjs +++ b/tests/worker-files/thread/testTaskFunctionObjectsWorker.mjs @@ -1,4 +1,4 @@ -import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' +import { KillBehaviors, ThreadWorker } from '../../../lib/index.mjs' import { factorial, fibonacci, diff --git a/tests/worker-files/thread/testWorker.mjs b/tests/worker-files/thread/testWorker.mjs index 9e32858af..71b48715a 100644 --- a/tests/worker-files/thread/testWorker.mjs +++ b/tests/worker-files/thread/testWorker.mjs @@ -1,4 +1,4 @@ -import { KillBehaviors, ThreadWorker } from '../../../lib/index.cjs' +import { KillBehaviors, ThreadWorker } from '../../../lib/index.mjs' import { TaskFunctions } from '../../test-types.cjs' import { executeTaskFunction } from '../../test-utils.cjs'