@@ -351,19 +351,22 @@ export default class Runner extends EventEmitter {
351351 }
352352
353353 _getScreenshotOptions ( ) {
354- let { path, pathPattern } = this . configuration . getOption ( OPTION_NAMES . screenshots ) || { } ;
354+ let { path, pathPattern, pathPatternOnFails } = this . configuration . getOption ( OPTION_NAMES . screenshots ) || { } ;
355355
356356 if ( ! path )
357357 path = this . configuration . getOption ( OPTION_NAMES . screenshotPath ) ;
358358
359359 if ( ! pathPattern )
360360 pathPattern = this . configuration . getOption ( OPTION_NAMES . screenshotPathPattern ) ;
361361
362- return { path, pathPattern } ;
362+ if ( ! pathPatternOnFails )
363+ pathPatternOnFails = this . configuration . getOption ( OPTION_NAMES . screenshotPathPatternOnFails ) ;
364+
365+ return { path, pathPattern, pathPatternOnFails } ;
363366 }
364367
365368 _validateScreenshotOptions ( ) {
366- const { path, pathPattern } = this . _getScreenshotOptions ( ) ;
369+ const { path, pathPattern, pathPatternOnFails } = this . _getScreenshotOptions ( ) ;
367370
368371 const disableScreenshots = this . configuration . getOption ( OPTION_NAMES . disableScreenshots ) || ! path ;
369372
@@ -383,6 +386,12 @@ export default class Runner extends EventEmitter {
383386
384387 this . configuration . mergeOptions ( { [ OPTION_NAMES . screenshots ] : { pathPattern } } ) ;
385388 }
389+
390+ if ( pathPatternOnFails ) {
391+ this . _validateScreenshotPath ( pathPatternOnFails , 'screenshots path pattern on fails' ) ;
392+
393+ this . configuration . mergeOptions ( { [ OPTION_NAMES . screenshots ] : { pathPatternOnFails } } ) ;
394+ }
386395 }
387396
388397 async _validateVideoOptions ( ) {
@@ -740,12 +749,13 @@ export default class Runner extends EventEmitter {
740749 screenshots ( ...options ) {
741750 let fullPage ;
742751 let thumbnails ;
752+ let pathPatternOnFails ;
743753 let [ path , takeOnFails , pathPattern ] = options ;
744754
745755 if ( options . length === 1 && options [ 0 ] && typeof options [ 0 ] === 'object' )
746- ( { path, takeOnFails, pathPattern, fullPage, thumbnails } = options [ 0 ] ) ;
756+ ( { path, takeOnFails, pathPattern, pathPatternOnFails , fullPage, thumbnails } = options [ 0 ] ) ;
747757
748- this . _options . screenshots = { path, takeOnFails, pathPattern, fullPage, thumbnails } ;
758+ this . _options . screenshots = { path, takeOnFails, pathPattern, pathPatternOnFails , fullPage, thumbnails } ;
749759
750760 return this ;
751761 }
0 commit comments