@@ -39,7 +39,7 @@ export const COMPASS_PATH = path.dirname(
3939) ;
4040export const LOG_PATH = path . resolve ( __dirname , '..' , '.log' ) ;
4141const OUTPUT_PATH = path . join ( LOG_PATH , 'output' ) ;
42- const SCREENSHOTS_PATH = path . join ( LOG_PATH , 'screenshots' ) ;
42+ export const SCREENSHOTS_PATH = path . join ( LOG_PATH , 'screenshots' ) ;
4343const COVERAGE_PATH = path . join ( LOG_PATH , 'coverage' ) ;
4444
4545let MONGODB_VERSION = '' ;
@@ -106,8 +106,6 @@ export const serverSatisfies = (
106106
107107// For the user data dirs
108108let i = 0 ;
109- // For the screenshots
110- let j = 0 ;
111109
112110interface Coverage {
113111 main ?: string ;
@@ -377,18 +375,6 @@ export class Compass {
377375 await fs . writeFile ( compassLogPath , compassLog . raw ) ;
378376 this . logs = compassLog . structured ;
379377 }
380-
381- async capturePage (
382- imgPathName = `screenshot-${ formattedDate ( ) } -${ ++ j } .png`
383- ) : Promise < boolean > {
384- try {
385- await this . browser . saveScreenshot ( path . join ( LOG_PATH , imgPathName ) ) ;
386- return true ;
387- } catch ( err ) {
388- console . warn ( ( err as Error ) . stack ) ;
389- return false ;
390- }
391- }
392378}
393379
394380interface StartCompassOptions {
@@ -987,9 +973,11 @@ export async function screenshotIfFailed(
987973 if ( test ) {
988974 if ( test . state === undefined ) {
989975 // if there's no state, then it is probably because the before() hook failed
990- await compass . capturePage ( screenshotPathName ( `${ test . fullTitle ( ) } -hook` ) ) ;
976+ await compass . browser . screenshot (
977+ screenshotPathName ( `${ test . fullTitle ( ) } -hook` )
978+ ) ;
991979 } else if ( test . state === 'failed' ) {
992- await compass . capturePage ( screenshotPathName ( test . fullTitle ( ) ) ) ;
980+ await compass . browser . screenshot ( screenshotPathName ( test . fullTitle ( ) ) ) ;
993981 }
994982 }
995983}
0 commit comments