comparadise-utils 0.0.11 → 0.0.12
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.
|
@@ -7,9 +7,9 @@ declare function getTestFolderPathFromScripts(rawName?: string): {
|
|
|
7
7
|
name: string;
|
|
8
8
|
screenshotsFolder: string;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
declare function verifyImages(): void;
|
|
11
|
+
type MatchScreenshotArgs = {
|
|
11
12
|
rawName?: string;
|
|
12
13
|
options?: Partial<Cypress.ScreenshotOptions>;
|
|
13
|
-
}
|
|
14
|
-
declare function verifyImages(): void;
|
|
14
|
+
};
|
|
15
15
|
declare function matchScreenshot(subject: Cypress.JQueryWithSelector | Window | Document | void, args?: MatchScreenshotArgs): void;
|
package/dist/match-screenshot.js
CHANGED
|
@@ -63,13 +63,11 @@ function matchScreenshot(subject, args) {
|
|
|
63
63
|
cy.task('compareScreenshots', screenshotsFolder).then(diffPixels => {
|
|
64
64
|
if (diffPixels === 0) {
|
|
65
65
|
cy.log(`✅ Actual image of ${name} was the same as base`);
|
|
66
|
-
return null;
|
|
67
66
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
else {
|
|
68
|
+
cy.task('log', `❌ Actual image of ${name} differed by ${diffPixels} pixels.`);
|
|
69
|
+
}
|
|
71
70
|
});
|
|
72
|
-
return null;
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
73
|
Cypress.Commands.add('matchScreenshot', { prevSubject: ['optional', 'element', 'window', 'document'] }, matchScreenshot);
|
package/dist/screenshots.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @returns true if path/base.png exists, false if not.
|
|
6
6
|
*/
|
|
7
7
|
export declare function baseExists(path: string): boolean;
|
|
8
|
-
export declare function createNewScreenshot(screenshotFolder: string):
|
|
8
|
+
export declare function createNewScreenshot(screenshotFolder: string): void;
|
|
9
9
|
/**
|
|
10
10
|
* Runs a visual regression test.
|
|
11
11
|
* @param screenshotFolder - Full screenshots folder where the base/new/diff
|
package/dist/screenshots.js
CHANGED
|
@@ -49,7 +49,6 @@ function createNewScreenshot(screenshotFolder) {
|
|
|
49
49
|
console.error('❌Unable to create new.png', err);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
|
-
return null;
|
|
53
52
|
}
|
|
54
53
|
exports.createNewScreenshot = createNewScreenshot;
|
|
55
54
|
/**
|
|
@@ -65,7 +64,7 @@ function compareScreenshots(screenshotFolder) {
|
|
|
65
64
|
// Create diff.png next to base and new for review
|
|
66
65
|
fs.writeFile((0, files_1.createImageFileName)(screenshotFolder, 'diff'), pngjs_1.PNG.sync.write(diff), err => {
|
|
67
66
|
if (err) {
|
|
68
|
-
console.error('❌Diff exists but unable to create diff.png', err);
|
|
67
|
+
console.error('❌ Diff exists but unable to create diff.png', err);
|
|
69
68
|
}
|
|
70
69
|
});
|
|
71
70
|
}
|
|
@@ -73,7 +72,7 @@ function compareScreenshots(screenshotFolder) {
|
|
|
73
72
|
// Delete created new.png. Not needed if there's no diff
|
|
74
73
|
fs.unlink(actualPath, err => {
|
|
75
74
|
if (err) {
|
|
76
|
-
console.error('❌No diff but unable to
|
|
75
|
+
console.error('❌ No diff but unable to delete actualPath}', err);
|
|
77
76
|
}
|
|
78
77
|
});
|
|
79
78
|
}
|
|
@@ -87,7 +86,7 @@ exports.compareScreenshots = compareScreenshots;
|
|
|
87
86
|
*/
|
|
88
87
|
function onAfterScreenshot(details) {
|
|
89
88
|
console.log('🧸 Screenshot was saved to:', details.path);
|
|
90
|
-
if (!details.path.match('
|
|
89
|
+
if (!details.path.match('visual')) {
|
|
91
90
|
return Promise.resolve({});
|
|
92
91
|
}
|
|
93
92
|
const getNewPath = (path) => {
|
|
@@ -102,7 +101,6 @@ function onAfterScreenshot(details) {
|
|
|
102
101
|
const newPathDir = newPath.substring(0, newPath.lastIndexOf('/'));
|
|
103
102
|
try {
|
|
104
103
|
fs.mkdirSync(newPathDir, { recursive: true });
|
|
105
|
-
console.log('🧸 No screenshot folder found in the package. Created new screenshot folder:', newPathDir);
|
|
106
104
|
}
|
|
107
105
|
catch (err) {
|
|
108
106
|
console.error('❌ Error creating new screenshot folder:', newPathDir, err);
|
package/package.json
CHANGED