import * as SUT from '../index' ; import { Browser , chromium } from 'playwright' ; describe ( 'get client rectangle' , ( ) : void => { let browser = undefined ; beforeEach ( ( ) : void => { } ) ; afterEach ( async ( ) : Promise < void > => { if ( browser ) { await browser . close ( ) ; } } ) ; test ( 'should return an error when selector is not found - chromium' , async ( ) : Promise < void > => { browser = await chromium . launch ( { headless : true } ) ; const browserContext = await browser . newContext ( { viewport : null } ) ; const page = await browserContext . newPage ( ) ; const expectedError = new Error ( 'page.$eval: Error: failed to find element matching selector "foobar"' ) ; await SUT . getClientRectangleOf ( 'foobar' , page ) . catch ( ( error ) : void => expect ( error ) . toMatchObject ( expectedError ) ) ; } ) ; } ) ;