diff --git a/changelog.md b/changelog.md index 0ebcf07..ac690b3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,12 @@ # Changelog +## 2025-07-24 - 2.3.2 - fix(tapbundle) +Fix TypeScript IDE warning about tapTools parameter possibly being undefined + +- Changed ITestFunction from interface with optional parameter to union type +- Updated test runner to handle both function signatures (with and without tapTools) +- Resolves IDE warnings while maintaining backward compatibility + ## 2025-05-26 - 2.3.1 - fix(tapParser/logger) Fix test duration reporting and summary formatting in TAP parser and logger diff --git a/package.json b/package.json index 4e7386b..92896a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@git.zone/tstest", - "version": "2.3.1", + "version": "2.3.2", "private": false, "description": "a test utility to run tests that match test/**/*.ts", "exports": { diff --git a/ts_tapbundle/tapbundle.classes.taptest.ts b/ts_tapbundle/tapbundle.classes.taptest.ts index b9b20b5..c946bcf 100644 --- a/ts_tapbundle/tapbundle.classes.taptest.ts +++ b/ts_tapbundle/tapbundle.classes.taptest.ts @@ -11,9 +11,9 @@ import { HrtMeasurement } from '@push.rocks/smarttime'; // interfaces export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout' | 'skipped'; -export interface ITestFunction { - (tapTools?: TapTools): Promise; -} +export type ITestFunction = + | ((tapTools: TapTools) => Promise) + | (() => Promise); export class TapTest { public description: string; @@ -173,7 +173,9 @@ export class TapTest { } // Run the test function with potential timeout - const testPromise = this.testFunction(this.tapTools); + const testPromise = this.testFunction.length === 0 + ? (this.testFunction as () => Promise)() + : (this.testFunction as (tapTools: TapTools) => Promise)(this.tapTools); const testReturnValue = timeoutPromise ? await Promise.race([testPromise, timeoutPromise]) : await testPromise;