File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,12 @@ Cypress.Commands.add(
130130 matchAgainstPath,
131131 } = getConfig ( options ) ;
132132
133+ const currentRetryNumber = (
134+ cy as unknown as { state : ( s : string ) => { currentRetry : ( ) => number } }
135+ )
136+ . state ( "test" )
137+ . currentRetry ( ) ;
138+
133139 return cy
134140 . then ( ( ) =>
135141 cy . task < { screenshotPath : string ; title : string } > (
@@ -139,6 +145,7 @@ Cypress.Commands.add(
139145 options . title || Cypress . currentTest . titlePath . join ( " " ) ,
140146 imagesPath,
141147 specPath : Cypress . spec . relative ,
148+ currentRetryNumber,
142149 } ,
143150 { log : false }
144151 )
Original file line number Diff line number Diff line change @@ -13,10 +13,12 @@ export const generateScreenshotPath = ({
1313 titleFromOptions,
1414 imagesPath,
1515 specPath,
16+ currentRetryNumber,
1617} : {
1718 titleFromOptions : string ;
1819 imagesPath : string ;
1920 specPath : string ;
21+ currentRetryNumber : number ;
2022} ) => {
2123 const parsePathPartVariables = ( pathPart : string , i : number ) => {
2224 if ( pathPart === PATH_VARIABLES . specPath ) {
@@ -40,6 +42,11 @@ export const generateScreenshotPath = ({
4042 if ( typeof nameCacheCounter [ screenshotPath ] === "undefined" ) {
4143 nameCacheCounter [ screenshotPath ] = - 1 ;
4244 }
45+
46+ // it's a retry of the same image, so let's decrease the counter
47+ if ( currentRetryNumber > 0 ) {
48+ -- nameCacheCounter [ screenshotPath ] ;
49+ }
4350 return path . join (
4451 IMAGE_SNAPSHOT_PREFIX ,
4552 `${ screenshotPath } #${ ++ nameCacheCounter [ screenshotPath ] } ${
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export const getScreenshotPathInfoTask = (cfg: {
3838 titleFromOptions : string ;
3939 imagesPath : string ;
4040 specPath : string ;
41+ currentRetryNumber : number ;
4142} ) => {
4243 const screenshotPath = generateScreenshotPath ( cfg ) ;
4344
You can’t perform that action at this time.
0 commit comments