Record tests as separate scenes

This commit is contained in:
Thomas Nordquist
2019-04-13 12:39:56 +02:00
parent d1f4bc678c
commit e6bcc00927
2 changed files with 111 additions and 53 deletions

24
src/spec/SceneBuilder.ts Normal file
View 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,
})
}
}