import { takeFullPageScreenshotAsBase64 , defaultFullPageScreenshotOptions , } from '../take-fullpage-screenshot-as-base64' ; import { Browser , chromium } from 'playwright' ; import * as path from 'path' ; describe ( 'full page screenshot' , ( ) : void => { let browser = undefined ; beforeEach ( ( ) : void => { } ) ; afterEach ( async ( ) : Promise < void > => { if ( browser ) { await browser . close ( ) ; } } ) ; test ( 'should take screenshot' , async ( ) : Promise < void > => { browser = await chromium . launch ( { headless : true } ) ; const context = await browser . newContext ( { viewport : null } ) ; const page = await context . newPage ( ) ; await page . goto ( `file:${ path . join ( __dirname , 'take-fullpage-screenshot-as-base64.test.html' ) }` ) ; const result = await takeFullPageScreenshotAsBase64 ( page , defaultFullPageScreenshotOptions ) ; expect ( typeof result ) . toBe ( 'string' ) ; expect ( result . startsWith ( 'iVBOR' ) ) . toBe ( true ) ; expect ( result . endsWith ( '==' ) || result . endsWith ( 'CYII=' ) ) . toBe ( true ) ; } ) ; } ) ;