Record tests as separate scenes
This commit is contained in:
24
src/spec/SceneBuilder.ts
Normal file
24
src/spec/SceneBuilder.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
export interface Scene {
|
||||
name: string,
|
||||
start: number
|
||||
stop: number
|
||||
duration: number
|
||||
}
|
||||
|
||||
export class SceneBuilder {
|
||||
public scenes: Array<Scene> = []
|
||||
public offset = Date.now()
|
||||
|
||||
public async record(name: string, callback: () => Promise<any>): Promise<any> {
|
||||
const start = Date.now() - this.offset
|
||||
await callback()
|
||||
const stop = Date.now() - this.offset
|
||||
|
||||
this.scenes.push({
|
||||
name,
|
||||
start,
|
||||
stop,
|
||||
duration: stop - start,
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user