From 07bd8246a1dd82a632aae7630670542e27a5aded Mon Sep 17 00:00:00 2001 From: Teimur Gasanov Date: Thu, 11 Sep 2025 11:55:41 +0600 Subject: [PATCH 1/2] feat: use blazediff instead of pixelmatch --- NOTICE | 2 +- source/frontend/package-lock.json | 31 ++++++++++--------- source/frontend/package.json | 2 +- .../src/tests/vitest/commands/screenshot.js | 8 ++--- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/NOTICE b/NOTICE index dcad7ee..f24fe33 100644 --- a/NOTICE +++ b/NOTICE @@ -1165,7 +1165,7 @@ fetch-blob under the MIT license. node-domexception under the MIT license. web-streams-polyfill under the MIT license. formdata-polyfill under the MIT license. -pixelmatch under the ISC license. +blazediff under the MIT license. vite-plugin-eslint2 under the MIT license. @types/eslint under the MIT license. @types/json-schema under the MIT license. diff --git a/source/frontend/package-lock.json b/source/frontend/package-lock.json index b4f4533..af44878 100644 --- a/source/frontend/package-lock.json +++ b/source/frontend/package-lock.json @@ -51,6 +51,7 @@ "@babel/plugin-transform-runtime": "^7.9.6", "@babel/preset-env": "^7.8.7", "@babel/preset-react": "^7.8.3", + "@blazediff/core": "^0.7.1", "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.1", "@testing-library/user-event": "^14.5.2", @@ -67,7 +68,6 @@ "jsdom": "^22.1.0", "msw": "^2.4.9", "node-fetch": "^3.3.1", - "pixelmatch": "^7.1.0", "playwright": "^1.51.1", "pngjs": "^7.0.0", "prettier": "^3.0.0", @@ -8670,6 +8670,22 @@ "node": ">=18" } }, + "node_modules/@blazediff/core": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@blazediff/core/-/core-0.7.1.tgz", + "integrity": "sha512-/r+qHoNqlrDoY2/895ZxRVeU6MWVn2KyrdQEGcZTS0dgx1ouupHZTXAKEsNDpIUJVYdTeq7WQ3dIzmLev5QW+Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@blazediff/types": "0.7.1" + } + }, + "node_modules/@blazediff/types": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@blazediff/types/-/types-0.7.1.tgz", + "integrity": "sha512-bG9xy9SksbYjNG4LdhzSbp3M2V6XqxM9Ob/iW5xm+yaOLOc7B26w5QSrozh+cpVRsRz2G6BtF6x+Og5YZPStgw==", + "dev": true + }, "node_modules/@bundled-es-modules/cookie": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@bundled-es-modules/cookie/-/cookie-2.0.1.tgz", @@ -19217,19 +19233,6 @@ "node": ">= 6" } }, - "node_modules/pixelmatch": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/pixelmatch/-/pixelmatch-7.1.0.tgz", - "integrity": "sha512-1wrVzJ2STrpmONHKBy228LM1b84msXDUoAzVEl0R8Mz4Ce6EPr+IVtxm8+yvrqLYMHswREkjYFaMxnyGnaY3Ng==", - "dev": true, - "license": "ISC", - "dependencies": { - "pngjs": "^7.0.0" - }, - "bin": { - "pixelmatch": "bin/pixelmatch" - } - }, "node_modules/playwright": { "version": "1.51.1", "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.51.1.tgz", diff --git a/source/frontend/package.json b/source/frontend/package.json index 0f88b5d..17509ed 100644 --- a/source/frontend/package.json +++ b/source/frontend/package.json @@ -14,6 +14,7 @@ "@babel/plugin-transform-runtime": "^7.9.6", "@babel/preset-env": "^7.8.7", "@babel/preset-react": "^7.8.3", + "@blazediff/core": "^0.7.1", "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.1", "@testing-library/user-event": "^14.5.2", @@ -30,7 +31,6 @@ "jsdom": "^22.1.0", "msw": "^2.4.9", "node-fetch": "^3.3.1", - "pixelmatch": "^7.1.0", "playwright": "^1.51.1", "pngjs": "^7.0.0", "prettier": "^3.0.0", diff --git a/source/frontend/src/tests/vitest/commands/screenshot.js b/source/frontend/src/tests/vitest/commands/screenshot.js index 0c7771a..9f87c8e 100644 --- a/source/frontend/src/tests/vitest/commands/screenshot.js +++ b/source/frontend/src/tests/vitest/commands/screenshot.js @@ -3,7 +3,7 @@ import {promises as fs} from 'node:fs'; import path from 'node:path'; -import pixelmatch from 'pixelmatch'; +import blazediff from '@blazediff/core'; import {PNG} from 'pngjs'; /** @@ -30,7 +30,7 @@ export const compareScreenshot = async (context, screenshotPath, options) => { testName, baselineDir = `${testDir}/__image_snapshots__`, diffDir = `${testDir}/__image_diffs__`, - threshold = 0.1, // recommended default in pixelmatch docs + threshold = 0.1, // recommended default in blazediff docs maxDiffPercentage = 1.0, updateBaseline = process.env.UPDATE_SNAPSHOTS === 'true', } = options; @@ -73,12 +73,12 @@ export const compareScreenshot = async (context, screenshotPath, options) => { }; } - // Create empty diff image buffer (pixelmatch will mutate this buffer to store the diff) + // Create empty diff image buffer (blazediff will mutate this buffer to store the diff) const {width, height} = img1; const diff = new PNG({width, height}); // Compare images - const numDiffPixels = pixelmatch( + const numDiffPixels = blazediff( img1.data, img2.data, diff.data, From 08b2dde7584355ec8cad8ca793131691f69982a7 Mon Sep 17 00:00:00 2001 From: Teimur Gasanov Date: Fri, 12 Sep 2025 15:54:35 +0600 Subject: [PATCH 2/2] feat: update to latest stable version --- source/frontend/package-lock.json | 16 ++++++++-------- source/frontend/package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/frontend/package-lock.json b/source/frontend/package-lock.json index af44878..db27a38 100644 --- a/source/frontend/package-lock.json +++ b/source/frontend/package-lock.json @@ -51,7 +51,7 @@ "@babel/plugin-transform-runtime": "^7.9.6", "@babel/preset-env": "^7.8.7", "@babel/preset-react": "^7.8.3", - "@blazediff/core": "^0.7.1", + "@blazediff/core": "^1.0.0", "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.1", "@testing-library/user-event": "^14.5.2", @@ -8671,19 +8671,19 @@ } }, "node_modules/@blazediff/core": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@blazediff/core/-/core-0.7.1.tgz", - "integrity": "sha512-/r+qHoNqlrDoY2/895ZxRVeU6MWVn2KyrdQEGcZTS0dgx1ouupHZTXAKEsNDpIUJVYdTeq7WQ3dIzmLev5QW+Q==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@blazediff/core/-/core-1.0.0.tgz", + "integrity": "sha512-k+SQhaWhf6NiTTDHkIM1OaWu2HhN8/1LsGv6G7a18CKmPrLHEG9qRJzKrMq3MlqlwtzzIQcQNB4VfNbnAoEPpw==", "dev": true, "license": "MIT", "dependencies": { - "@blazediff/types": "0.7.1" + "@blazediff/types": "1.0.0" } }, "node_modules/@blazediff/types": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@blazediff/types/-/types-0.7.1.tgz", - "integrity": "sha512-bG9xy9SksbYjNG4LdhzSbp3M2V6XqxM9Ob/iW5xm+yaOLOc7B26w5QSrozh+cpVRsRz2G6BtF6x+Og5YZPStgw==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@blazediff/types/-/types-1.0.0.tgz", + "integrity": "sha512-uV3SnRogVgXeSgFY9PVDOneHI6/jmx/KSXkzPYBTwLOpb94YTm7aVWkJMoIDasCXShu9B3JBOVF7l/+JsMqVJg==", "dev": true }, "node_modules/@bundled-es-modules/cookie": { diff --git a/source/frontend/package.json b/source/frontend/package.json index 17509ed..f2a3d0b 100644 --- a/source/frontend/package.json +++ b/source/frontend/package.json @@ -14,7 +14,7 @@ "@babel/plugin-transform-runtime": "^7.9.6", "@babel/preset-env": "^7.8.7", "@babel/preset-react": "^7.8.3", - "@blazediff/core": "^0.7.1", + "@blazediff/core": "^1.0.0", "@testing-library/jest-dom": "^6.4.2", "@testing-library/react": "^14.2.1", "@testing-library/user-event": "^14.5.2",