comparadise-utils 1.8.1 → 1.8.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/images.js +5 -3
- package/dist/index.js +1 -1
- package/dist/match-screenshot.js +1 -1
- package/package.json +1 -2
package/dist/images.js
CHANGED
|
@@ -31,7 +31,7 @@ const fs = __importStar(require("fs"));
|
|
|
31
31
|
const pngjs_1 = require("pngjs");
|
|
32
32
|
const pixelmatch_1 = __importDefault(require("pixelmatch"));
|
|
33
33
|
const PIXELMATCH_OPTIONS = {
|
|
34
|
-
threshold: 0.3
|
|
34
|
+
threshold: 0.3,
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* Helper function to create reusable image resizer
|
|
@@ -79,7 +79,7 @@ function alignImagesToSameSize(firstImage, secondImage) {
|
|
|
79
79
|
// Fill resized area with black transparent pixels
|
|
80
80
|
return [
|
|
81
81
|
fillSizeDifference(firstImageWidth, firstImageHeight)(resizedFirst),
|
|
82
|
-
fillSizeDifference(secondImageWidth, secondImageHeight)(resizedSecond)
|
|
82
|
+
fillSizeDifference(secondImageWidth, secondImageHeight)(resizedSecond),
|
|
83
83
|
];
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
@@ -92,7 +92,9 @@ function getDiffPixels(basePath, actualPath) {
|
|
|
92
92
|
const rawBase = pngjs_1.PNG.sync.read(fs.readFileSync(basePath));
|
|
93
93
|
const rawActual = pngjs_1.PNG.sync.read(fs.readFileSync(actualPath));
|
|
94
94
|
const hasSizeMismatch = rawBase.height !== rawActual.height || rawBase.width !== rawActual.width;
|
|
95
|
-
const [base, actual] = hasSizeMismatch
|
|
95
|
+
const [base, actual] = hasSizeMismatch
|
|
96
|
+
? alignImagesToSameSize(rawBase, rawActual)
|
|
97
|
+
: [rawBase, rawActual];
|
|
96
98
|
const diff = new pngjs_1.PNG({ width: base.width, height: base.height });
|
|
97
99
|
const diffPixels = (0, pixelmatch_1.default)(actual.data, base.data, diff.data, diff.width, diff.height, PIXELMATCH_OPTIONS);
|
|
98
100
|
return { diffPixels, diff };
|
package/dist/index.js
CHANGED
package/dist/match-screenshot.js
CHANGED
|
@@ -26,7 +26,7 @@ function getTestFolderPathFromScripts(rawName) {
|
|
|
26
26
|
const screenshotsFolder = `${SCREENSHOTS_FOLDER_NAME}/${relativeTestPath.substring(0, relativeTestPath.lastIndexOf(testName))}${name}`;
|
|
27
27
|
return {
|
|
28
28
|
name,
|
|
29
|
-
screenshotsFolder
|
|
29
|
+
screenshotsFolder,
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
function verifyImages() {
|
package/package.json
CHANGED
|
@@ -30,11 +30,10 @@
|
|
|
30
30
|
"dist",
|
|
31
31
|
"types"
|
|
32
32
|
],
|
|
33
|
-
"version": "1.8.
|
|
33
|
+
"version": "1.8.2",
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsc && tsc --project tsconfig.types.json",
|
|
36
36
|
"bump-version": "pnpm version $NEW_VERSION",
|
|
37
|
-
"format": "prettier --write .",
|
|
38
37
|
"lint": "eslint . --max-warnings=0",
|
|
39
38
|
"postbuild": "echo \"require('./dist/match-screenshot');\" > commands.js && echo \"export {};\" > types/index.js",
|
|
40
39
|
"prebuild": "rm -rf dist types",
|