@@ -410,6 +410,10 @@ const takeScreenshot = (Cypress, state, screenshotConfig, options: TakeScreensho
410
410
. finally ( after )
411
411
}
412
412
413
+ interface InternalScreenshotOptions extends Partial < Cypress . Loggable & Cypress . Timeoutable & Cypress . ScreenshotOptions > {
414
+ _log ?: any
415
+ }
416
+
413
417
export default function ( Commands , Cypress , cy , state , config ) {
414
418
// failure screenshot when not interactive
415
419
Cypress . on ( 'runnable:after:run:async' , ( test , runnable ) => {
@@ -440,8 +444,7 @@ export default function (Commands, Cypress, cy, state, config) {
440
444
} )
441
445
442
446
Commands . addAll ( { prevSubject : [ 'optional' , 'element' , 'window' , 'document' ] } , {
443
- // TODO: any -> Partial<Loggable & Timeoutable & ScreenshotOptions>
444
- screenshot ( subject , name , options : any = { } ) {
447
+ screenshot ( subject , name , options : Partial < Cypress . Loggable & Cypress . Timeoutable & Cypress . ScreenshotOptions > = { } ) {
445
448
let userOptions = options
446
449
447
450
if ( _ . isObject ( name ) ) {
@@ -463,16 +466,16 @@ export default function (Commands, Cypress, cy, state, config) {
463
466
// TODO: handle hook titles
464
467
const runnable = state ( 'runnable' )
465
468
466
- options = _ . defaults ( { } , userOptions , {
469
+ const _options : InternalScreenshotOptions = _ . defaults ( { } , userOptions , {
467
470
log : true ,
468
471
timeout : config ( 'responseTimeout' ) ,
469
472
} )
470
473
471
474
const isWin = $dom . isWindow ( subject )
472
475
473
- let screenshotConfig : any = _ . pick ( options , 'capture' , 'scale' , 'disableTimersAndAnimations' , 'overwrite' , 'blackout' , 'waitForCommandSynchronization' , 'padding' , 'clip' , 'onBeforeScreenshot' , 'onAfterScreenshot' )
476
+ let screenshotConfig : any = _ . pick ( _options , 'capture' , 'scale' , 'disableTimersAndAnimations' , 'overwrite' , 'blackout' , 'waitForCommandSynchronization' , 'padding' , 'clip' , 'onBeforeScreenshot' , 'onAfterScreenshot' )
474
477
475
- screenshotConfig = $Screenshot . validate ( screenshotConfig , 'screenshot' , options . _log )
478
+ screenshotConfig = $Screenshot . validate ( screenshotConfig , 'screenshot' , _options . _log )
476
479
screenshotConfig = _ . extend ( $Screenshot . getConfig ( ) , screenshotConfig )
477
480
478
481
// set this regardless of options.log b/c its used by the
@@ -488,10 +491,10 @@ export default function (Commands, Cypress, cy, state, config) {
488
491
consoleProps . name = name
489
492
}
490
493
491
- if ( options . log ) {
492
- options . _log = Cypress . log ( {
494
+ if ( _options . log ) {
495
+ _options . _log = Cypress . log ( {
493
496
message : name ,
494
- timeout : options . timeout ,
497
+ timeout : _options . timeout ,
495
498
consoleProps ( ) {
496
499
return consoleProps
497
500
} ,
@@ -500,7 +503,7 @@ export default function (Commands, Cypress, cy, state, config) {
500
503
501
504
if ( ! isWin && subject && subject . length > 1 ) {
502
505
$errUtils . throwErrByPath ( 'screenshot.multiple_elements' , {
503
- log : options . _log ,
506
+ log : _options . _log ,
504
507
args : { numElements : subject . length } ,
505
508
} )
506
509
}
@@ -515,8 +518,8 @@ export default function (Commands, Cypress, cy, state, config) {
515
518
name,
516
519
subject,
517
520
runnable,
518
- log : options . _log ,
519
- timeout : options . timeout ,
521
+ log : _options . _log ,
522
+ timeout : _options . timeout ,
520
523
} )
521
524
. then ( ( props ) => {
522
525
const { duration, path, size } = props
0 commit comments