comparadise-utils 1.15.0 → 1.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/screenshots.js +22 -8
- package/package.json +1 -1
package/dist/screenshots.js
CHANGED
|
@@ -70,6 +70,28 @@ function compareScreenshots(screenshotFolder) {
|
|
|
70
70
|
return diffPixels;
|
|
71
71
|
}
|
|
72
72
|
exports.compareScreenshots = compareScreenshots;
|
|
73
|
+
const trimPostfix = (path) => {
|
|
74
|
+
const imgExt = '.png';
|
|
75
|
+
const attemptPostfixRegex = new RegExp(`\\s\\(attempt \\d+\\)${imgExt}$`);
|
|
76
|
+
if (attemptPostfixRegex.test(path)) {
|
|
77
|
+
return path.replace(attemptPostfixRegex, imgExt);
|
|
78
|
+
}
|
|
79
|
+
return path;
|
|
80
|
+
};
|
|
81
|
+
const getNewPath = (path) => {
|
|
82
|
+
let newPath;
|
|
83
|
+
if (path.includes('___')) {
|
|
84
|
+
newPath = path.slice(path.lastIndexOf('___') + 3);
|
|
85
|
+
if (newPath.startsWith('/')) {
|
|
86
|
+
newPath = `.${newPath}`;
|
|
87
|
+
}
|
|
88
|
+
console.log(newPath);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
newPath = path;
|
|
92
|
+
}
|
|
93
|
+
return trimPostfix(newPath);
|
|
94
|
+
};
|
|
73
95
|
/**
|
|
74
96
|
* Renames all root cypress screenshots to where the test was actually run.
|
|
75
97
|
* Should NOT be used standalone. Works with the matchScreenshot task.
|
|
@@ -80,14 +102,6 @@ function onAfterScreenshot(details) {
|
|
|
80
102
|
if (!details.path.match('cypress')) {
|
|
81
103
|
return Promise.resolve({});
|
|
82
104
|
}
|
|
83
|
-
const getNewPath = (path) => {
|
|
84
|
-
let newPath = path.slice(path.lastIndexOf('___') + 3);
|
|
85
|
-
console.log(newPath);
|
|
86
|
-
if (newPath.startsWith('/')) {
|
|
87
|
-
newPath = `.${newPath}`;
|
|
88
|
-
}
|
|
89
|
-
return newPath;
|
|
90
|
-
};
|
|
91
105
|
const newPath = getNewPath(details.path);
|
|
92
106
|
const newPathDir = newPath.substring(0, newPath.lastIndexOf('/'));
|
|
93
107
|
try {
|