import * as SUT from '../../playwright-fluent' ; import { sizeOf } from '../../../devices' ; import { FakeServer } from 'simple-fake-server' ; import * as path from 'path' ; describe ( 'Playwright Fluent - recordVideo()' , ( ) : void => { let p ; let fakeServer = undefined ; beforeAll ( ( ) => { fakeServer = new FakeServer ( 1247 ) ; fakeServer . start ( ) ; } ) ; afterAll ( ( ) => { if ( fakeServer ) { fakeServer . stop ( ) ; } } ) ; beforeEach ( ( ) : void => { p = new SUT . PlaywrightFluent ( ) ; } ) ; afterEach ( async ( ) : Promise < void > => { await p . close ( ) ; } ) ; test ( 'should record video' , async ( ) : Promise < void > => { const url = `file:${ path . join ( __dirname , 'record-video.test.html' ) }` ; const responseBody = { prop1 : 'foobar' , } ; const responseBodyBaz = { prop1 : 'foobaz' , } ; const responseHeaders = { 'foo-header' : 'bar' , } ; fakeServer && fakeServer . http . get ( ) . to ( '/foobar' ) . willReturn ( responseBody , 200 , responseHeaders ) ; fakeServer && fakeServer . http . get ( ) . to ( '/yo' ) . willReturn ( responseBodyBaz , 200 , responseHeaders ) ; await p . withBrowser ( 'chromium' ) . withOptions ( { headless : true } ) . withWindowSize ( sizeOf . _1024x768 ) . withCursor ( ) . clearVideoFilesOlderThan ( __dirname , 60 ) . recordVideo ( { dir : __dirname , size : sizeOf . _1024x768 } ) . navigateTo ( url ) . wait ( 3000 ) . close ( ) ; const videoPath = await p . getRecordedVideoPath ( ) ; expect ( videoPath ) . toBeDefined ( ) ; } ) ; } ) ;