File tree 3 files changed +15
-0
lines changed
3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,12 @@ Cypress.Commands.add(
130
130
matchAgainstPath,
131
131
} = getConfig ( options ) ;
132
132
133
+ const currentRetryNumber = (
134
+ cy as unknown as { state : ( s : string ) => { currentRetry : ( ) => number } }
135
+ )
136
+ . state ( "test" )
137
+ . currentRetry ( ) ;
138
+
133
139
return cy
134
140
. then ( ( ) =>
135
141
cy . task < { screenshotPath : string ; title : string } > (
@@ -139,6 +145,7 @@ Cypress.Commands.add(
139
145
options . title || Cypress . currentTest . titlePath . join ( " " ) ,
140
146
imagesPath,
141
147
specPath : Cypress . spec . relative ,
148
+ currentRetryNumber,
142
149
} ,
143
150
{ log : false }
144
151
)
Original file line number Diff line number Diff line change @@ -13,10 +13,12 @@ export const generateScreenshotPath = ({
13
13
titleFromOptions,
14
14
imagesPath,
15
15
specPath,
16
+ currentRetryNumber,
16
17
} : {
17
18
titleFromOptions : string ;
18
19
imagesPath : string ;
19
20
specPath : string ;
21
+ currentRetryNumber : number ;
20
22
} ) => {
21
23
const parsePathPartVariables = ( pathPart : string , i : number ) => {
22
24
if ( pathPart === PATH_VARIABLES . specPath ) {
@@ -40,6 +42,11 @@ export const generateScreenshotPath = ({
40
42
if ( typeof nameCacheCounter [ screenshotPath ] === "undefined" ) {
41
43
nameCacheCounter [ screenshotPath ] = - 1 ;
42
44
}
45
+
46
+ // it's a retry of the same image, so let's decrease the counter
47
+ if ( currentRetryNumber > 0 ) {
48
+ -- nameCacheCounter [ screenshotPath ] ;
49
+ }
43
50
return path . join (
44
51
IMAGE_SNAPSHOT_PREFIX ,
45
52
`${ screenshotPath } #${ ++ nameCacheCounter [ screenshotPath ] } ${
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ export const getScreenshotPathInfoTask = (cfg: {
38
38
titleFromOptions : string ;
39
39
imagesPath : string ;
40
40
specPath : string ;
41
+ currentRetryNumber : number ;
41
42
} ) => {
42
43
const screenshotPath = generateScreenshotPath ( cfg ) ;
43
44
You can’t perform that action at this time.
0 commit comments