import * as SUT from '../index' ; import { Page } from 'playwright' ; describe ( 'record page errors' , ( ) : void => { beforeEach ( ( ) : void => { } ) ; test ( 'should return an error when browser has not been launched' , async ( ) : Promise < void > => { const page = undefined ; const errors = [ ] ; const callback = ( error ) => errors . push ( error ) ; const expectedError = new Error ( 'Cannot record page errors because no browser has been launched' ) ; await SUT . recordPageErrors ( page , callback ) . catch ( ( error ) : void => expect ( error ) . toMatchObject ( expectedError ) ) ; } ) ; } ) ;