Compare commits

..

1 Commits

Author SHA1 Message Date
Juergen Kunz
008844a9e2 fix(tapbundle): Fix TypeScript IDE warning about tapTools parameter possibly being undefined 2025-07-24 22:24:52 +00:00
3 changed files with 14 additions and 5 deletions

View File

@@ -1,5 +1,12 @@
# Changelog # 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) ## 2025-05-26 - 2.3.1 - fix(tapParser/logger)
Fix test duration reporting and summary formatting in TAP parser and logger Fix test duration reporting and summary formatting in TAP parser and logger

View File

@@ -1,6 +1,6 @@
{ {
"name": "@git.zone/tstest", "name": "@git.zone/tstest",
"version": "2.3.1", "version": "2.3.2",
"private": false, "private": false,
"description": "a test utility to run tests that match test/**/*.ts", "description": "a test utility to run tests that match test/**/*.ts",
"exports": { "exports": {

View File

@@ -11,9 +11,9 @@ import { HrtMeasurement } from '@push.rocks/smarttime';
// interfaces // interfaces
export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout' | 'skipped'; export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout' | 'skipped';
export interface ITestFunction<T> { export type ITestFunction<T> =
(tapTools?: TapTools): Promise<T>; | ((tapTools: TapTools) => Promise<T>)
} | (() => Promise<T>);
export class TapTest<T = unknown> { export class TapTest<T = unknown> {
public description: string; public description: string;
@@ -173,7 +173,9 @@ export class TapTest<T = unknown> {
} }
// Run the test function with potential timeout // Run the test function with potential timeout
const testPromise = this.testFunction(this.tapTools); const testPromise = this.testFunction.length === 0
? (this.testFunction as () => Promise<T>)()
: (this.testFunction as (tapTools: TapTools) => Promise<T>)(this.tapTools);
const testReturnValue = timeoutPromise const testReturnValue = timeoutPromise
? await Promise.race([testPromise, timeoutPromise]) ? await Promise.race([testPromise, timeoutPromise])
: await testPromise; : await testPromise;