@@ -14,13 +14,12 @@ import { po } from '@qavajs/po-playwright';
1414import {
1515 saveScreenshotAfterStep ,
1616 saveScreenshotBeforeStep ,
17- saveTrace ,
18- saveVideo ,
19- traceArchive
17+ saveVideo
2018} from './utils/utils' ;
2119import { readFile } from 'node:fs/promises' ;
2220import { createJSEngine } from './selectorEngines' ;
2321import browserManager , { BrowserManager } from './browserManager' ;
22+ import tracingManager from './utils/tracingManager' ;
2423
2524declare global {
2625 var browser : Browser
@@ -47,12 +46,7 @@ Before({name: 'Init'}, async function () {
4746 config . driverConfig . capabilities . recordVideo = config . driverConfig . video ;
4847 }
4948 await browserManager . launchDriver ( 'default' , config . driverConfig ) ;
50- if ( config . driverConfig . trace ) {
51- await context . tracing . start ( {
52- screenshots : true ,
53- snapshots : true
54- } ) ;
55- }
49+ await tracingManager . start ( driverConfig ) ;
5650 po . init ( page , { timeout : config . driverConfig . timeout . present , logger : this } ) ;
5751 po . register ( config . pageObject ) ;
5852 global . browserManager = browserManager ;
@@ -80,20 +74,19 @@ AfterStep(async function (step: ITestStepHookParameter) {
8074} ) ;
8175
8276After ( { name : 'Teardown' } , async function ( scenario : ITestCaseHookParameter ) {
83- if ( saveTrace ( config . driverConfig , scenario ) ) {
84- const path = traceArchive ( config . driverConfig , scenario ) ;
85- await context . tracing . stop ( { path } ) ;
86- if ( config . driverConfig ?. trace . attach ) {
87- const zipBuffer : Buffer = await readFile ( path ) ;
88- this . attach ( zipBuffer . toString ( 'base64' ) , 'base64:application/zip' ) ;
89- }
90- }
91- await browserManager . teardown ( ) ;
77+ await tracingManager . stop ( config . driverConfig , this , scenario ) ;
78+ await browserManager . teardown ( { reuseSession : config . driverConfig . reuseSession } ) ;
9279 if ( saveVideo ( config . driverConfig , scenario ) ) {
9380 if ( config . driverConfig ?. video . attach ) {
94- const videoPath = await page . video ( ) ?. path ( ) ?? '' ;
95- const zipBuffer : Buffer = await readFile ( videoPath ) ;
96- this . attach ( zipBuffer . toString ( 'base64' ) , 'base64:video/webm' ) ;
81+ const video = page . video ( ) ;
82+ console . log ( video )
83+ if ( video ) {
84+ const videoPath = await video . path ( ) ;
85+ const zipBuffer : Buffer = await readFile ( videoPath ) ;
86+ this . attach ( zipBuffer . toString ( 'base64' ) , 'base64:video/webm' ) ;
87+ } else {
88+ console . warn ( 'Video was not recorded' ) ;
89+ }
9790 }
9891 }
9992} ) ;
0 commit comments