@@ -80,34 +80,35 @@ const getImagesDir = (options: Cypress.MatchImageOptions) => {
80
80
return imagesDir ;
81
81
} ;
82
82
83
- export const getConfig = ( options : Cypress . MatchImageOptions ) => {
83
+ const getImagesPathConfig = ( options : Cypress . MatchImageOptions ) => {
84
84
const imagesDir = getImagesDir ( options ) ;
85
85
86
- return {
87
- scaleFactor :
88
- options . forceDeviceScaleFactor === false ||
89
- getPluginEnv ( "forceDeviceScaleFactor" ) === false
90
- ? 1
91
- : 1 / window . devicePixelRatio ,
92
- createMissingImages :
93
- options . createMissingImages ??
94
- getPluginEnv ( "createMissingImages" ) ??
95
- true ,
96
- updateImages : options . updateImages ?? getPluginEnv ( "updateImages" ) ?? false ,
97
- imagesPath :
98
- ( imagesDir && `{spec_path}/${ imagesDir } ` ) ||
99
- options . imagesPath ||
100
- getPluginEnv ( "imagesPath" ) ||
101
- "{spec_path}/__image_snapshots__" ,
102
- maxDiffThreshold :
103
- options . maxDiffThreshold ?? getPluginEnv ( "maxDiffThreshold" ) ?? 0.01 ,
104
- diffConfig : options . diffConfig || getPluginEnv ( "diffConfig" ) || { } ,
105
- screenshotConfig :
106
- options . screenshotConfig || getPluginEnv ( "screenshotConfig" ) || { } ,
107
- matchAgainstPath : options . matchAgainstPath || undefined ,
108
- } ;
86
+ return (
87
+ ( imagesDir && `{spec_path}/${ imagesDir } ` ) ||
88
+ options . imagesPath ||
89
+ getPluginEnv ( "imagesPath" ) ||
90
+ "{spec_path}/__image_snapshots__"
91
+ ) ;
109
92
} ;
110
93
94
+ export const getConfig = ( options : Cypress . MatchImageOptions ) => ( {
95
+ scaleFactor :
96
+ options . forceDeviceScaleFactor === false ||
97
+ getPluginEnv ( "forceDeviceScaleFactor" ) === false
98
+ ? 1
99
+ : 1 / window . devicePixelRatio ,
100
+ createMissingImages :
101
+ options . createMissingImages ?? getPluginEnv ( "createMissingImages" ) ?? true ,
102
+ updateImages : options . updateImages ?? getPluginEnv ( "updateImages" ) ?? false ,
103
+ imagesPath : getImagesPathConfig ( options ) ,
104
+ maxDiffThreshold :
105
+ options . maxDiffThreshold ?? getPluginEnv ( "maxDiffThreshold" ) ?? 0.01 ,
106
+ diffConfig : options . diffConfig || getPluginEnv ( "diffConfig" ) || { } ,
107
+ screenshotConfig :
108
+ options . screenshotConfig || getPluginEnv ( "screenshotConfig" ) || { } ,
109
+ matchAgainstPath : options . matchAgainstPath || undefined ,
110
+ } ) ;
111
+
111
112
Cypress . Commands . add (
112
113
"matchImage" ,
113
114
{ prevSubject : "optional" } ,
0 commit comments