diff --git a/package.json b/package.json index 17d859a..fb7c656 100644 --- a/package.json +++ b/package.json @@ -37,24 +37,24 @@ "postpublish": "git push origin && git push origin -f --tags" }, "dependencies": { - "acquerello": "^1.1.2", + "acquerello": "^2.0.0", "hdr-histogram-js": "^3.0.0", "table": "^6.8.1" }, "devDependencies": { - "@cowtech/eslint-config": "^8.10.0", - "@swc/cli": "^0.1.62", - "@swc/core": "^1.3.94", - "@types/node": "^20.8.7", - "@types/tap": "^15.0.10", + "@cowtech/eslint-config": "^9.0.0", + "@swc/cli": "^0.1.63", + "@swc/core": "^1.3.101", + "@types/node": "^20.10.5", + "@types/tap": "^15.0.11", "c8": "^8.0.1", "chokidar": "^3.5.3", "concurrently": "^8.2.2", - "prettier": "^3.0.3", + "prettier": "^3.1.1", "proxyquire": "^2.1.3", - "tap": "^18.5.2", - "ts-node": "^10.9.1", - "typescript": "^5.2.2" + "tap": "^18.6.1", + "ts-node": "^10.9.2", + "typescript": "^5.3.3" }, "engines": { "node": ">= 18.18.0" diff --git a/src/index.ts b/src/index.ts index c9a153d..1e06442 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,7 @@ import { isMainThread, Worker, workerData } from 'node:worker_threads' import { defaultOptions, + type Result, runnerPath, type Callback, type Context, @@ -88,7 +89,7 @@ function run(context: Context): void { context.current++ if (context.onTestEnd) { - context.onTestEnd(name, result, worker) + context.onTestEnd(name, result as Result, worker) } scheduleNextTest(context) diff --git a/src/runner.ts b/src/runner.ts index 8358448..8c7e121 100644 --- a/src/runner.ts +++ b/src/runner.ts @@ -1,4 +1,5 @@ import { isMainThread, parentPort, workerData } from 'node:worker_threads' +import { type WorkerContext } from './models.js' import { runWorker } from './worker.js' if (isMainThread) { @@ -34,11 +35,11 @@ chain .then(() => { // Run the worker runWorker( - workerData, + workerData as WorkerContext, value => { parentPort!.postMessage({ type: 'cronometro.result', payload: value }) }, - process.exit + (code: number) => process.exit(code) ) }) .catch(error => { diff --git a/src/worker.ts b/src/worker.ts index 72e3bd8..ea534a1 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -103,7 +103,7 @@ function runTestIteration(context: TestContext): void { } catch (error) { // If a error was thrown, only handle if the original function length is 0, which means it's a sync error, otherwise propagate if (context.test.length === 0) { - context.handler(error) + context.handler(error as Error) return } diff --git a/test/genericErrorHandling.test.ts b/test/genericErrorHandling.test.ts index 1b80f78..cb968bd 100644 --- a/test/genericErrorHandling.test.ts +++ b/test/genericErrorHandling.test.ts @@ -2,10 +2,10 @@ import { isMainThread } from 'node:worker_threads' import t from 'tap' -import { cronometro } from '../src/index.js' +import { cronometro, type Tests } from '../src/index.js' if (!isMainThread) { - cronometro(undefined as any, () => false) + cronometro(undefined as unknown as Tests, () => false) } else { t.test('Generic error handling', async t => { const results = await cronometro(