11import { join } from 'node:path' ;
22
3- import { LogEventType , SCREENSHOTS_DIRECTORY_PATH } from '../constants/internal' ;
3+ import {
4+ ADDITIONAL_STEP_TIMEOUT ,
5+ LogEventType ,
6+ SCREENSHOTS_DIRECTORY_PATH ,
7+ } from '../constants/internal' ;
48import { step } from '../step' ;
59import { getPlaywrightPage } from '../useContext' ;
10+ import { getDimensionsString , getPngDimensions } from '../utils/screenshot' ;
611
712import type { Page } from '@playwright/test' ;
813
@@ -13,6 +18,7 @@ type Options = Parameters<Page['screenshot']>[0];
1318 */
1419export const takeScreenshot = async ( options : Options = { } ) : Promise < void > => {
1520 const { path : pathToScreenshot , ...optionsWithoutPath } = options ;
21+ const { timeout} = options ;
1622
1723 await step (
1824 'Take a screenshot of the page' ,
@@ -24,8 +30,15 @@ export const takeScreenshot = async (options: Options = {}): Promise<void> => {
2430
2531 const page = getPlaywrightPage ( ) ;
2632
27- await page . screenshot ( options ) ;
33+ const screenshot = await page . screenshot ( options ) ;
34+ const dimensions = getDimensionsString ( getPngDimensions ( screenshot ) ) ;
35+
36+ return { dimensions} ;
37+ } ,
38+ {
39+ payload : { pathToScreenshot, ...optionsWithoutPath } ,
40+ ...( timeout !== undefined ? { timeout : timeout + ADDITIONAL_STEP_TIMEOUT } : undefined ) ,
41+ type : LogEventType . InternalAction ,
2842 } ,
29- { payload : { pathToScreenshot, ...optionsWithoutPath } , type : LogEventType . InternalAction } ,
3043 ) ;
3144} ;
0 commit comments