Skip to content

Commit 9a4e733

Browse files

8 files changed

+62
-16
lines changed

dist/plugins.js

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugins.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plugins.mjs

+8-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const PATH_VARIABLES = {
3434
const WINDOWS_LIKE_DRIVE_REGEX = /^[A-Z]:$/;
3535
const METADATA_KEY = "FRSOURCE_CPVRD_V";
3636

37-
var version = "3.0.1";
37+
var version = "3.1.0";
3838

3939
function isHighSurrogate(codePoint) {
4040
return codePoint >= 0xd800 && codePoint <= 0xdbff;
@@ -143,7 +143,8 @@ const nameCacheCounter = {};
143143
const generateScreenshotPath = ({
144144
titleFromOptions,
145145
imagesPath,
146-
specPath
146+
specPath,
147+
currentRetryNumber
147148
}) => {
148149
const parsePathPartVariables = (pathPart, i) => {
149150
if (pathPart === PATH_VARIABLES.specPath) {
@@ -163,6 +164,11 @@ const generateScreenshotPath = ({
163164

164165
if (typeof nameCacheCounter[screenshotPath] === "undefined") {
165166
nameCacheCounter[screenshotPath] = -1;
167+
} // it's a retry of the same image, so let's decrease the counter
168+
169+
170+
if (currentRetryNumber > 0) {
171+
--nameCacheCounter[screenshotPath];
166172
}
167173

168174
return path.join(IMAGE_SNAPSHOT_PREFIX, `${screenshotPath} #${++nameCacheCounter[screenshotPath]}${FILE_SUFFIX.actual}.png`);

dist/plugins.mjs.map

+1-1
Large diffs are not rendered by default.

dist/support.js

+21-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/support.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/support.mjs

+21-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ const getConfig = options => {
6666
maxDiffThreshold: options.maxDiffThreshold || Cypress.env("pluginVisualRegressionMaxDiffThreshold") || 0.01,
6767
diffConfig: options.diffConfig || Cypress.env("pluginVisualRegressionDiffConfig") || {},
6868
screenshotConfig: options.screenshotConfig || Cypress.env("pluginVisualRegressionScreenshotConfig") || {},
69-
remoteScreenshotServiceUrl: options.remoteScreenshotServiceUrl || Cypress.env("pluginVisualRegressionRemoteScreenshotServiceUrl")
69+
remoteScreenshotServiceUrl: options.remoteScreenshotServiceUrl || Cypress.env("pluginVisualRegressionRemoteScreenshotServiceUrl"),
70+
matchAgainstPath: options.matchAgainstPath || undefined
7071
};
7172
};
7273
Cypress.Commands.add("matchImage", {
@@ -81,12 +82,15 @@ Cypress.Commands.add("matchImage", {
8182
maxDiffThreshold,
8283
diffConfig,
8384
screenshotConfig,
84-
remoteScreenshotServiceUrl
85+
remoteScreenshotServiceUrl,
86+
matchAgainstPath
8587
} = getConfig(options);
88+
const currentRetryNumber = cy.state("test").currentRetry();
8689
return cy.then(() => cy.task(TASK.getScreenshotPathInfo, {
8790
titleFromOptions: options.title || Cypress.currentTest.titlePath.join(" "),
8891
imagesPath,
89-
specPath: Cypress.spec.relative
92+
specPath: Cypress.spec.relative,
93+
currentRetryNumber
9094
}, {
9195
log: false
9296
})).then(({
@@ -129,7 +133,7 @@ Cypress.Commands.add("matchImage", {
129133
}).then(imgPath => cy.task(TASK.compareImages, {
130134
scaleFactor,
131135
imgNew: imgPath,
132-
imgOld: imgPath.replace(FILE_SUFFIX.actual, ""),
136+
imgOld: matchAgainstPath || imgPath.replace(FILE_SUFFIX.actual, ""),
133137
updateImages,
134138
maxDiffThreshold,
135139
diffConfig
@@ -166,6 +170,19 @@ Cypress.Commands.add("matchImage", {
166170
log.set("consoleProps", () => res);
167171
throw constructCypressError(log, new Error(res.message));
168172
}
173+
174+
return {
175+
diffValue: res.imgDiff,
176+
imgNewPath: imgPath,
177+
imgPath: imgPath.replace(FILE_SUFFIX.actual, ""),
178+
imgDiffPath: imgPath.replace(FILE_SUFFIX.actual, FILE_SUFFIX.diff),
179+
imgNewBase64: res.imgNewBase64,
180+
imgBase64: res.imgOldBase64,
181+
imgDiffBase64: res.imgDiffBase64,
182+
imgNew: typeof res.imgNewBase64 === "string" ? Cypress.Buffer.from(res.imgNewBase64, "base64") : undefined,
183+
img: typeof res.imgOldBase64 === "string" ? Cypress.Buffer.from(res.imgOldBase64, "base64") : undefined,
184+
imgDiff: typeof res.imgDiffBase64 === "string" ? Cypress.Buffer.from(res.imgDiffBase64, "base64") : undefined
185+
};
169186
});
170187
});
171188

dist/support.mjs.map

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)