comparadise-utils 0.0.7 → 0.0.9
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/match-screenshot.js
CHANGED
|
@@ -30,10 +30,7 @@ function matchScreenshot(subject, args) {
|
|
|
30
30
|
const { rawName, options = {} } = args || {};
|
|
31
31
|
forceFont();
|
|
32
32
|
verifyImages();
|
|
33
|
-
const
|
|
34
|
-
if (!screenshotsFolder) {
|
|
35
|
-
throw new Error('No screenshots folder found!');
|
|
36
|
-
}
|
|
33
|
+
const screenshotsFolder = 'cypress/screenshots';
|
|
37
34
|
const testPath = Cypress.spec.relative;
|
|
38
35
|
const lastSlashIndex = testPath.lastIndexOf('/');
|
|
39
36
|
const testPathWithoutFileName = testPath.substring(0, lastSlashIndex);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.onAfterScreenshot = void 0;
|
|
27
|
+
const fs = __importStar(require("fs"));
|
|
28
|
+
function onAfterScreenshot(details) {
|
|
29
|
+
console.log('🧸 Screenshot was saved to:', details.path);
|
|
30
|
+
if (!details.path.match('visual')) {
|
|
31
|
+
return Promise.resolve({});
|
|
32
|
+
}
|
|
33
|
+
const newPath = details.path.substring(details.path.lastIndexOf('cypress/screenshots'));
|
|
34
|
+
const newPathDir = newPath.substring(0, newPath.lastIndexOf('/'));
|
|
35
|
+
try {
|
|
36
|
+
fs.mkdirSync(newPathDir, { recursive: true });
|
|
37
|
+
console.log('🧸 No screenshot folder found in the package. Created new screenshot folder:', newPathDir);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
console.error('❌ Error creating new screenshot folder:', newPathDir, err);
|
|
41
|
+
}
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
fs.rename(details.path, newPath, err => {
|
|
44
|
+
if (err) {
|
|
45
|
+
reject(err);
|
|
46
|
+
}
|
|
47
|
+
resolve({ path: newPath });
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.onAfterScreenshot = onAfterScreenshot;
|
package/package.json
CHANGED