🚧This project is currently under development and may undergo changes 🚧
📸Cypress screenshot diffing commands with multiple screenshot folders ability
This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:
npm install --save-dev cypress-screenshot-diffcypress-screenshot-diff extends Cypress' cy command and adds matchScreenshot().
-
Add this line to your project's
cypress/support/commands.js:const { addCommands } = require("cypress-screenshot-diff"); addCommands();
-
Add/Update these tasks to your project's
cypress/plugins/index.jsconst { addScreenshotDiffPlugin } = require("cypress-screenshot-diff"); module.exports = (on, config) => { addScreenshotDiffPlugin(on,config); };
To configure cypress-screenshot-diff, use the following custom command:
cy.configureCypressScreenshotDiff(config)cy.matchScreenshot();
cy.get("h1").matchScreenshot();In Cypress' infancy, before visual regression plugins, I made my own for personal use using jimp's diff utility and Cypress. However, as I started working with bigger monorepos, keeping the screenshots in a single folder, which is where Cypress takes screenshots, was getting pretty hefty for devs. Unfortunately, Cypress does not allow for dynamic screenshot folder roots either, and I didn't find any that did what I wanted structure wise. So I reworked my existing implementation to use pixelmatch and allow for different screenshot folders. If you come accross the same problem, hopefully this will help!