diff --git a/README.md b/README.md index 96acb787..c252e1e9 100644 --- a/README.md +++ b/README.md @@ -248,6 +248,14 @@ Screenshots in Cypress do not scale to the viewport size by default. You can cha +
I've upgraded version of this plugin and all on my baseline images has been automatically updated. Why? + +Sometimes we need to do a breaking change in image comparison or image generation algorithms. To provide you with the easiest upgrade path - the plugin updates your baseline images automatically. Just commit them to your repository after the plugin upgrade and you are good to go! + +
+ +DIFF_IMAGES_VERSION + ## Questions Don’t hesitate to ask a question directly on the [discussions board](https://github.com/FRSOURCE/cypress-plugin-visual-regression-diff/discussions)! diff --git a/src/image.utils.ts b/src/image.utils.ts index f71225d5..652b5bf1 100644 --- a/src/image.utils.ts +++ b/src/image.utils.ts @@ -5,16 +5,20 @@ import sharp from "sharp"; import metaPngPkg from "meta-png"; const { addMetadata, getMetadata } = metaPngPkg; import glob from "glob"; -import { version } from "../package.json"; import { wasScreenshotUsed } from "./screenshotPath.utils"; import { METADATA_KEY } from "./constants"; +// version of images generated by this plugin +// bump only when there is a breaking change to: +// image comparison or image generation algorithms +const DIFF_IMAGES_VERSION = "1"; + export const addPNGMetadata = (png: Buffer) => - addMetadata(png, METADATA_KEY, version /* c8 ignore next */); + addMetadata(png, METADATA_KEY, DIFF_IMAGES_VERSION /* c8 ignore next */); export const getPNGMetadata = (png: Buffer) => getMetadata(png, METADATA_KEY /* c8 ignore next */); export const isImageCurrentVersion = (png: Buffer) => - getPNGMetadata(png) === version; + getPNGMetadata(png) === DIFF_IMAGES_VERSION; export const isImageGeneratedByPlugin = (png: Buffer) => !!getPNGMetadata(png /* c8 ignore next */);