fix(core): update
This commit is contained in:
		| @@ -23,12 +23,14 @@ const test3 = tap.test( | |||||||
|   } |   } | ||||||
| ); | ); | ||||||
|  |  | ||||||
| const test4 = tap.skip.test('my 4th test -> should fail', async (tools) => { | const test4 = tap.test('my 4th test -> should fail', async (tools) => { | ||||||
|   tools.allowFailure(); |   tools.allowFailure(); | ||||||
|   expect(false).to.be.true; |   expect(false).to.be.true; | ||||||
|  |   return 'hello'; | ||||||
| }); | }); | ||||||
|  |  | ||||||
| const test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => { | const test5 = tap.test('my 5th test -> should pass in about 500ms', async (tools) => { | ||||||
|  |   const test4Result = await test4.testResultPromise; | ||||||
|   tools.timeout(1000); |   tools.timeout(1000); | ||||||
|   await tools.delayFor(500); |   await tools.delayFor(500); | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ import * as plugins from './tapbundle.plugins'; | |||||||
|  |  | ||||||
| import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask'; | import { IPreTaskFunction, PreTask } from './tapbundle.classes.pretask'; | ||||||
| import { TapTest, ITestFunction } from './tapbundle.classes.taptest'; | import { TapTest, ITestFunction } from './tapbundle.classes.taptest'; | ||||||
| export class Tap { | export class Tap <T> { | ||||||
|   /** |   /** | ||||||
|    * skips a test |    * skips a test | ||||||
|    * tests marked with tap.skip.test() are never executed |    * tests marked with tap.skip.test() are never executed | ||||||
| @@ -20,14 +20,14 @@ export class Tap { | |||||||
|    * only executes tests marked as ONLY |    * only executes tests marked as ONLY | ||||||
|    */ |    */ | ||||||
|   public only = { |   public only = { | ||||||
|     test: (descriptionArg: string, testFunctionArg: ITestFunction) => { |     test: (descriptionArg: string, testFunctionArg: ITestFunction<T>) => { | ||||||
|       this.test(descriptionArg, testFunctionArg, 'only'); |       this.test(descriptionArg, testFunctionArg, 'only'); | ||||||
|     }, |     }, | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   private _tapPreTasks: PreTask[] = []; |   private _tapPreTasks: PreTask[] = []; | ||||||
|   private _tapTests: TapTest[] = []; |   private _tapTests: TapTest<any>[] = []; | ||||||
|   private _tapTestsOnly: TapTest[] = []; |   private _tapTestsOnly: TapTest<any>[] = []; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * Normal test function, will run one by one |    * Normal test function, will run one by one | ||||||
| @@ -36,10 +36,10 @@ export class Tap { | |||||||
|    */ |    */ | ||||||
|   public test( |   public test( | ||||||
|     testDescription: string, |     testDescription: string, | ||||||
|     testFunction: ITestFunction, |     testFunction: ITestFunction<T>, | ||||||
|     modeArg: 'normal' | 'only' | 'skip' = 'normal' |     modeArg: 'normal' | 'only' | 'skip' = 'normal' | ||||||
|   ) { |   ) { | ||||||
|     const localTest = new TapTest({ |     const localTest = new TapTest<T>({ | ||||||
|       description: testDescription, |       description: testDescription, | ||||||
|       testFunction, |       testFunction, | ||||||
|       parallel: false, |       parallel: false, | ||||||
|   | |||||||
| @@ -9,25 +9,25 @@ import { HrtMeasurement } from '@pushrocks/smarttime'; | |||||||
| // interfaces | // interfaces | ||||||
| export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout'; | export type TTestStatus = 'success' | 'error' | 'pending' | 'errorAfterSuccess' | 'timeout'; | ||||||
|  |  | ||||||
| export type ITestFunction = (tapTools?: TapTools) => Promise<any>; | export interface ITestFunction <T = unknown> { (tapTools?: TapTools): Promise<T> }; | ||||||
|  |  | ||||||
| export class TapTest { | export class TapTest <T = unknown> { | ||||||
|   public description: string; |   public description: string; | ||||||
|   public failureAllowed: boolean; |   public failureAllowed: boolean; | ||||||
|   public hrtMeasurement: HrtMeasurement; |   public hrtMeasurement: HrtMeasurement; | ||||||
|   public parallel: boolean; |   public parallel: boolean; | ||||||
|   public status: TTestStatus; |   public status: TTestStatus; | ||||||
|   public tapTools: TapTools; |   public tapTools: TapTools; | ||||||
|   public testFunction: ITestFunction; |   public testFunction: ITestFunction<T>; | ||||||
|   public testKey: number; // the testKey the position in the test qeue. Set upon calling .run() |   public testKey: number; // the testKey the position in the test qeue. Set upon calling .run() | ||||||
|   private testDeferred: Deferred<TapTest> = plugins.smartpromise.defer(); |   private testDeferred: Deferred<TapTest<T>> = plugins.smartpromise.defer(); | ||||||
|   public testPromise: Promise<TapTest> = this.testDeferred.promise; |   public testPromise: Promise<TapTest<T>> = this.testDeferred.promise; | ||||||
|   private testResultDeferred: Deferred<any> = plugins.smartpromise.defer(); |   private testResultDeferred: Deferred<T> = plugins.smartpromise.defer(); | ||||||
|   public testResultPromise: Promise<any> = this.testResultDeferred.promise; |   public testResultPromise: Promise<T> = this.testResultDeferred.promise; | ||||||
|   /** |   /** | ||||||
|    * constructor |    * constructor | ||||||
|    */ |    */ | ||||||
|   constructor(optionsArg: { description: string; testFunction: ITestFunction; parallel: boolean }) { |   constructor(optionsArg: { description: string; testFunction: ITestFunction<T>; parallel: boolean }) { | ||||||
|     this.description = optionsArg.description; |     this.description = optionsArg.description; | ||||||
|     this.hrtMeasurement = new HrtMeasurement(); |     this.hrtMeasurement = new HrtMeasurement(); | ||||||
|     this.parallel = optionsArg.parallel; |     this.parallel = optionsArg.parallel; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user