From c607391d37451f36faaf9f3b9bfe1f041664f05a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 22 Feb 2026 23:22:20 +0100 Subject: [PATCH] test: update imports to .mjs files MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- tests/circular-buffer.test.mjs | 2 +- tests/pools/abstract-pool.test.mjs | 12 ++++++------ tests/pools/cluster/dynamic.test.mjs | 2 +- tests/pools/cluster/fixed.test.mjs | 4 ++-- .../selection-strategies-utils.test.mjs | 4 ++-- .../selection-strategies.test.mjs | 4 ++-- ...round-robin-worker-choice-strategy.test.mjs | 16 ++++++++-------- .../worker-choice-strategies-context.test.mjs | 18 +++++++++--------- tests/pools/thread/dynamic.test.mjs | 2 +- tests/pools/thread/fixed.test.mjs | 4 ++-- tests/pools/utils.test.mjs | 12 ++++++------ tests/pools/worker-node.test.mjs | 12 ++++++------ tests/utils.test.mjs | 4 ++-- tests/worker/abort-error.test.mjs | 2 +- tests/worker/abstract-worker.test.mjs | 4 ++-- tests/worker/cluster-worker.test.mjs | 4 ++-- tests/worker/thread-worker.test.mjs | 4 ++-- vitest.config.ts | 1 - 18 files changed, 55 insertions(+), 56 deletions(-) diff --git a/tests/circular-buffer.test.mjs b/tests/circular-buffer.test.mjs index a0224650d..d86f74418 100644 --- a/tests/circular-buffer.test.mjs +++ b/tests/circular-buffer.test.mjs @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { CircularBuffer, defaultBufferSize } from '../lib/circular-buffer.cjs' +import { CircularBuffer, defaultBufferSize } from '../lib/circular-buffer.mjs' describe('Circular buffer test suite', () => { it('Verify that circular buffer can be instantiated', () => { diff --git a/tests/pools/abstract-pool.test.mjs b/tests/pools/abstract-pool.test.mjs index 4a026d9b0..9748f9e60 100644 --- a/tests/pools/abstract-pool.test.mjs +++ b/tests/pools/abstract-pool.test.mjs @@ -6,7 +6,7 @@ import { dirname, join } from 'node:path' import { fileURLToPath } from 'node:url' import { describe, expect, it } from 'vitest' -import { CircularBuffer } from '../../lib/circular-buffer.cjs' +import { CircularBuffer } from '../../lib/circular-buffer.mjs' import { DynamicClusterPool, DynamicThreadPool, @@ -16,11 +16,11 @@ import { PoolTypes, WorkerChoiceStrategies, WorkerTypes, -} from '../../lib/index.cjs' -import { WorkerNode } from '../../lib/pools/worker-node.cjs' -import { PriorityQueue } from '../../lib/queues/priority-queue.cjs' -import { defaultBucketSize } from '../../lib/queues/queue-types.cjs' -import { DEFAULT_TASK_NAME } from '../../lib/utils.cjs' +} from '../../lib/index.mjs' +import { WorkerNode } from '../../lib/pools/worker-node.mjs' +import { PriorityQueue } from '../../lib/queues/priority-queue.mjs' +import { defaultBucketSize } from '../../lib/queues/queue-types.mjs' +import { DEFAULT_TASK_NAME } from '../../lib/utils.mjs' import { waitPoolEvents } from '../test-utils.cjs' describe('Abstract pool test suite', () => { diff --git a/tests/pools/cluster/dynamic.test.mjs b/tests/pools/cluster/dynamic.test.mjs index 337a97f06..1028b0007 100644 --- a/tests/pools/cluster/dynamic.test.mjs +++ b/tests/pools/cluster/dynamic.test.mjs @@ -4,7 +4,7 @@ import { DynamicClusterPool, PoolEvents, WorkerChoiceStrategies, -} from '../../../lib/index.cjs' +} from '../../../lib/index.mjs' import { TaskFunctions } from '../../test-types.cjs' import { sleep, waitPoolEvents, waitWorkerEvents } from '../../test-utils.cjs' diff --git a/tests/pools/cluster/fixed.test.mjs b/tests/pools/cluster/fixed.test.mjs index 1c0e7f8e4..3f41c6e4c 100644 --- a/tests/pools/cluster/fixed.test.mjs +++ b/tests/pools/cluster/fixed.test.mjs @@ -1,8 +1,8 @@ import cluster from 'node:cluster' import { afterAll, beforeAll, describe, expect, it } from 'vitest' -import { FixedClusterPool, PoolEvents } from '../../../lib/index.cjs' -import { DEFAULT_TASK_NAME } from '../../../lib/utils.cjs' +import { FixedClusterPool, PoolEvents } from '../../../lib/index.mjs' +import { DEFAULT_TASK_NAME } from '../../../lib/utils.mjs' import { TaskFunctions } from '../../test-types.cjs' import { sleep, waitWorkerEvents } from '../../test-utils.cjs' diff --git a/tests/pools/selection-strategies/selection-strategies-utils.test.mjs b/tests/pools/selection-strategies/selection-strategies-utils.test.mjs index d93f808b0..f55f59f87 100644 --- a/tests/pools/selection-strategies/selection-strategies-utils.test.mjs +++ b/tests/pools/selection-strategies/selection-strategies-utils.test.mjs @@ -1,10 +1,10 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' -import { FixedClusterPool, FixedThreadPool } from '../../../lib/index.cjs' +import { FixedClusterPool, FixedThreadPool } from '../../../lib/index.mjs' import { buildWorkerChoiceStrategyOptions, getWorkerChoiceStrategiesRetries, -} from '../../../lib/pools/selection-strategies/selection-strategies-utils.cjs' +} from '../../../lib/pools/selection-strategies/selection-strategies-utils.mjs' describe('Selection strategies utils test suite', () => { const numberOfWorkers = 4 diff --git a/tests/pools/selection-strategies/selection-strategies.test.mjs b/tests/pools/selection-strategies/selection-strategies.test.mjs index 54ed4a854..df69f2f66 100644 --- a/tests/pools/selection-strategies/selection-strategies.test.mjs +++ b/tests/pools/selection-strategies/selection-strategies.test.mjs @@ -1,14 +1,14 @@ import { randomInt } from 'node:crypto' import { describe, expect, it } from 'vitest' -import { CircularBuffer } from '../../../lib/circular-buffer.cjs' +import { CircularBuffer } from '../../../lib/circular-buffer.mjs' import { DynamicClusterPool, DynamicThreadPool, FixedClusterPool, FixedThreadPool, WorkerChoiceStrategies, -} from '../../../lib/index.cjs' +} from '../../../lib/index.mjs' describe('Selection strategies test suite', () => { const min = 0 diff --git a/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.mjs b/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.mjs index 7ae280759..2c19b03bf 100644 --- a/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.mjs +++ b/tests/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.test.mjs @@ -1,14 +1,14 @@ import { randomInt } from 'node:crypto' import { afterAll, beforeAll, describe, expect, it } from 'vitest' -import { FixedThreadPool } from '../../../lib/index.cjs' -import { FairShareWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/fair-share-worker-choice-strategy.cjs' -import { InterleavedWeightedRoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.cjs' -import { LeastBusyWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-busy-worker-choice-strategy.cjs' -import { LeastEluWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-elu-worker-choice-strategy.cjs' -import { LeastUsedWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-used-worker-choice-strategy.cjs' -import { RoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/round-robin-worker-choice-strategy.cjs' -import { WeightedRoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.cjs' +import { FixedThreadPool } from '../../../lib/index.mjs' +import { FairShareWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/fair-share-worker-choice-strategy.mjs' +import { InterleavedWeightedRoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.mjs' +import { LeastBusyWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-busy-worker-choice-strategy.mjs' +import { LeastEluWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-elu-worker-choice-strategy.mjs' +import { LeastUsedWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-used-worker-choice-strategy.mjs' +import { RoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/round-robin-worker-choice-strategy.mjs' +import { WeightedRoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.mjs' describe('Weighted round robin worker choice strategy test suite', () => { const max = 3 diff --git a/tests/pools/selection-strategies/worker-choice-strategies-context.test.mjs b/tests/pools/selection-strategies/worker-choice-strategies-context.test.mjs index cbfc2aaa3..1b7045c45 100644 --- a/tests/pools/selection-strategies/worker-choice-strategies-context.test.mjs +++ b/tests/pools/selection-strategies/worker-choice-strategies-context.test.mjs @@ -5,15 +5,15 @@ import { DynamicThreadPool, FixedThreadPool, WorkerChoiceStrategies, -} from '../../../lib/index.cjs' -import { FairShareWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/fair-share-worker-choice-strategy.cjs' -import { InterleavedWeightedRoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.cjs' -import { LeastBusyWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-busy-worker-choice-strategy.cjs' -import { LeastEluWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-elu-worker-choice-strategy.cjs' -import { LeastUsedWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-used-worker-choice-strategy.cjs' -import { RoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/round-robin-worker-choice-strategy.cjs' -import { WeightedRoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.cjs' -import { WorkerChoiceStrategiesContext } from '../../../lib/pools/selection-strategies/worker-choice-strategies-context.cjs' +} from '../../../lib/index.mjs' +import { FairShareWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/fair-share-worker-choice-strategy.mjs' +import { InterleavedWeightedRoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/interleaved-weighted-round-robin-worker-choice-strategy.mjs' +import { LeastBusyWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-busy-worker-choice-strategy.mjs' +import { LeastEluWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-elu-worker-choice-strategy.mjs' +import { LeastUsedWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/least-used-worker-choice-strategy.mjs' +import { RoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/round-robin-worker-choice-strategy.mjs' +import { WeightedRoundRobinWorkerChoiceStrategy } from '../../../lib/pools/selection-strategies/weighted-round-robin-worker-choice-strategy.mjs' +import { WorkerChoiceStrategiesContext } from '../../../lib/pools/selection-strategies/worker-choice-strategies-context.mjs' describe('Worker choice strategies context test suite', () => { const min = 1 diff --git a/tests/pools/thread/dynamic.test.mjs b/tests/pools/thread/dynamic.test.mjs index 6bf049dfd..21d880352 100644 --- a/tests/pools/thread/dynamic.test.mjs +++ b/tests/pools/thread/dynamic.test.mjs @@ -4,7 +4,7 @@ import { DynamicThreadPool, PoolEvents, WorkerChoiceStrategies, -} from '../../../lib/index.cjs' +} from '../../../lib/index.mjs' import { TaskFunctions } from '../../test-types.cjs' import { sleep, waitPoolEvents, waitWorkerEvents } from '../../test-utils.cjs' diff --git a/tests/pools/thread/fixed.test.mjs b/tests/pools/thread/fixed.test.mjs index ae46df803..48e0fcdaf 100644 --- a/tests/pools/thread/fixed.test.mjs +++ b/tests/pools/thread/fixed.test.mjs @@ -1,7 +1,7 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest' -import { FixedThreadPool, PoolEvents } from '../../../lib/index.cjs' -import { DEFAULT_TASK_NAME } from '../../../lib/utils.cjs' +import { FixedThreadPool, PoolEvents } from '../../../lib/index.mjs' +import { DEFAULT_TASK_NAME } from '../../../lib/utils.mjs' import { TaskFunctions } from '../../test-types.cjs' import { sleep, waitWorkerEvents } from '../../test-utils.cjs' diff --git a/tests/pools/utils.test.mjs b/tests/pools/utils.test.mjs index 6d75a0066..cc3e980ea 100644 --- a/tests/pools/utils.test.mjs +++ b/tests/pools/utils.test.mjs @@ -2,8 +2,8 @@ import { Worker as ClusterWorker } from 'node:cluster' import { Worker as ThreadWorker } from 'node:worker_threads' import { describe, expect, it } from 'vitest' -import { CircularBuffer } from '../../lib/circular-buffer.cjs' -import { WorkerTypes } from '../../lib/index.cjs' +import { CircularBuffer } from '../../lib/circular-buffer.mjs' +import { WorkerTypes } from '../../lib/index.mjs' import { checkValidWorkerNodeKeys, createWorker, @@ -11,8 +11,8 @@ import { getDefaultTasksQueueOptions, initWorkerInfo, updateMeasurementStatistics, -} from '../../lib/pools/utils.cjs' -import { MeasurementHistorySize } from '../../lib/pools/worker.cjs' +} from '../../lib/pools/utils.mjs' +import { MeasurementHistorySize } from '../../lib/pools/worker.mjs' describe('Pool utils test suite', () => { it('Verify DEFAULT_MEASUREMENT_STATISTICS_REQUIREMENTS values', () => { @@ -118,7 +118,7 @@ describe('Pool utils test suite', () => { expect( createWorker( WorkerTypes.cluster, - './tests/worker-files/cluster/testWorker.mjs', + './tests/worker-files/cluster/testWorker.cjs', {} ) ).toBeInstanceOf(ClusterWorker) @@ -145,7 +145,7 @@ describe('Pool utils test suite', () => { }) const clusterWorker = createWorker( WorkerTypes.cluster, - './tests/worker-files/cluster/testWorker.mjs', + './tests/worker-files/cluster/testWorker.cjs', {} ) const clusterWorkerInfo = initWorkerInfo(clusterWorker) diff --git a/tests/pools/worker-node.test.mjs b/tests/pools/worker-node.test.mjs index 35243c03b..2803d80ce 100644 --- a/tests/pools/worker-node.test.mjs +++ b/tests/pools/worker-node.test.mjs @@ -2,12 +2,12 @@ import { Worker as ClusterWorker } from 'node:cluster' import { MessageChannel, Worker as ThreadWorker } from 'node:worker_threads' import { afterAll, beforeAll, describe, expect, it } from 'vitest' -import { CircularBuffer } from '../../lib/circular-buffer.cjs' -import { WorkerTypes } from '../../lib/index.cjs' -import { WorkerNode } from '../../lib/pools/worker-node.cjs' -import { MeasurementHistorySize } from '../../lib/pools/worker.cjs' -import { PriorityQueue } from '../../lib/queues/priority-queue.cjs' -import { DEFAULT_TASK_NAME } from '../../lib/utils.cjs' +import { CircularBuffer } from '../../lib/circular-buffer.mjs' +import { WorkerTypes } from '../../lib/index.mjs' +import { WorkerNode } from '../../lib/pools/worker-node.mjs' +import { MeasurementHistorySize } from '../../lib/pools/worker.mjs' +import { PriorityQueue } from '../../lib/queues/priority-queue.mjs' +import { DEFAULT_TASK_NAME } from '../../lib/utils.mjs' describe('Worker node test suite', () => { let clusterWorkerNode, threadWorkerNode diff --git a/tests/utils.test.mjs b/tests/utils.test.mjs index 242f7d59e..6db56dc78 100644 --- a/tests/utils.test.mjs +++ b/tests/utils.test.mjs @@ -3,7 +3,7 @@ import os from 'node:os' import { useFakeTimers } from 'sinon' import { describe, expect, it } from 'vitest' -import { KillBehaviors } from '../lib/index.cjs' +import { KillBehaviors } from '../lib/index.mjs' import { availableParallelism, average, @@ -20,7 +20,7 @@ import { round, secureRandom, sleep, -} from '../lib/utils.cjs' +} from '../lib/utils.mjs' describe('Utils test suite', () => { it('Verify DEFAULT_TASK_NAME value', () => { diff --git a/tests/worker/abort-error.test.mjs b/tests/worker/abort-error.test.mjs index 143227e03..245de00a3 100644 --- a/tests/worker/abort-error.test.mjs +++ b/tests/worker/abort-error.test.mjs @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest' -import { AbortError } from '../../lib/worker/abort-error.cjs' +import { AbortError } from '../../lib/worker/abort-error.mjs' describe('Abort error test suite', () => { it('Verify constructor() behavior', () => { diff --git a/tests/worker/abstract-worker.test.mjs b/tests/worker/abstract-worker.test.mjs index 158197004..03e4e87a1 100644 --- a/tests/worker/abstract-worker.test.mjs +++ b/tests/worker/abstract-worker.test.mjs @@ -6,8 +6,8 @@ import { KillBehaviors, ThreadWorker, WorkerChoiceStrategies, -} from '../../lib/index.cjs' -import { DEFAULT_TASK_NAME, EMPTY_FUNCTION } from '../../lib/utils.cjs' +} from '../../lib/index.mjs' +import { DEFAULT_TASK_NAME, EMPTY_FUNCTION } from '../../lib/utils.mjs' describe('Abstract worker test suite', () => { class StubWorkerWithMainWorker extends ThreadWorker { diff --git a/tests/worker/cluster-worker.test.mjs b/tests/worker/cluster-worker.test.mjs index 46f94cd0c..ec455085a 100644 --- a/tests/worker/cluster-worker.test.mjs +++ b/tests/worker/cluster-worker.test.mjs @@ -1,8 +1,8 @@ import { restore, stub } from 'sinon' import { afterEach, describe, expect, it } from 'vitest' -import { ClusterWorker } from '../../lib/index.cjs' -import { DEFAULT_TASK_NAME } from '../../lib/utils.cjs' +import { ClusterWorker } from '../../lib/index.mjs' +import { DEFAULT_TASK_NAME } from '../../lib/utils.mjs' describe('Cluster worker test suite', () => { afterEach(() => { diff --git a/tests/worker/thread-worker.test.mjs b/tests/worker/thread-worker.test.mjs index 966f0cf07..cfc140ecc 100644 --- a/tests/worker/thread-worker.test.mjs +++ b/tests/worker/thread-worker.test.mjs @@ -1,8 +1,8 @@ import { restore, stub } from 'sinon' import { afterEach, describe, expect, it } from 'vitest' -import { ThreadWorker } from '../../lib/index.cjs' -import { DEFAULT_TASK_NAME } from '../../lib/utils.cjs' +import { ThreadWorker } from '../../lib/index.mjs' +import { DEFAULT_TASK_NAME } from '../../lib/utils.mjs' describe('Thread worker test suite', () => { afterEach(() => { diff --git a/vitest.config.ts b/vitest.config.ts index 957a41a39..21c98edaa 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -5,7 +5,6 @@ export default defineConfig({ coverage: { provider: 'v8', reporter: ['text', 'html', 'lcov'], - reportsDirectory: 'outputs/coverage', thresholds: { branches: 90, functions: 90, -- 2.43.0