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.
@@ -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 {
package/package.json CHANGED
@@ -32,7 +32,7 @@
32
32
  "dist",
33
33
  "types"
34
34
  ],
35
- "version": "1.15.0",
35
+ "version": "1.15.2",
36
36
  "scripts": {
37
37
  "build": "tsc && tsc --project tsconfig.types.json",
38
38
  "bump-version": "pnpm version $NEW_VERSION",