fix(tapbundle): Fix TypeScript IDE warning about tapTools parameter possibly being undefined
This commit is contained in:
		| @@ -11,9 +11,9 @@ import { HrtMeasurement } from '@push.rocks/smarttime'; | ||||
| // interfaces | ||||
| export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout' | 'skipped'; | ||||
|  | ||||
| export interface ITestFunction<T> { | ||||
|   (tapTools?: TapTools): Promise<T>; | ||||
| } | ||||
| export type ITestFunction<T> =  | ||||
|   | ((tapTools: TapTools) => Promise<T>) | ||||
|   | (() => Promise<T>); | ||||
|  | ||||
| export class TapTest<T = unknown> { | ||||
|   public description: string; | ||||
| @@ -173,7 +173,9 @@ export class TapTest<T = unknown> { | ||||
|         } | ||||
|          | ||||
|         // 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  | ||||
|           ? await Promise.race([testPromise, timeoutPromise]) | ||||
|           : await testPromise; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user