Gathering detailed insights and metrics for cypress-image-snapshot
Gathering detailed insights and metrics for cypress-image-snapshot
Gathering detailed insights and metrics for cypress-image-snapshot
Gathering detailed insights and metrics for cypress-image-snapshot
@types/cypress-image-snapshot
TypeScript definitions for cypress-image-snapshot
@simonsmith/cypress-image-snapshot
Cypress Image Snapshot binds jest-image-snapshot's image diffing logic to Cypress commands.
@frsource/cypress-plugin-visual-regression-diff
Perform visual regression test with a nice GUI as help. 💅 Only for Cypress!
cypress-image-snapshot-fork-2
Fork of cypress-image-snapshot: Cypress Image Snapshot binds jest-image-snapshot's image diffing logic to Cypress commands.
npm install cypress-image-snapshot
Typescript
Module System
Min. Node Version
Node Version
NPM Version
59.5
Supply Chain
51
Quality
70.8
Maintenance
50
Vulnerability
93.2
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
893 Stars
175 Commits
156 Forks
16 Watchers
68 Branches
11 Contributors
Updated on May 04, 2025
Latest Version
4.0.1
Package Id
cypress-image-snapshot@4.0.1
Unpacked Size
21.40 kB
Size
6.65 kB
File Count
8
NPM Version
6.14.8
Node Version
12.20.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Cypress Image Snapshot binds jest-image-snapshot's image diffing logic to Cypress.io commands. The goal is to catch visual regressions during integration tests.
When using cypress open
, errors are displayed in the GUI.
When an image diff fails, a composite image is constructed.
When using cypress run
and --reporter cypress-image-snapshot/reporter
, diffs are output to your terminal.
Install from npm
1npm install --save-dev cypress-image-snapshot
then add the following in your project's <rootDir>/cypress/plugins/index.js
:
1const { 2 addMatchImageSnapshotPlugin, 3} = require('cypress-image-snapshot/plugin'); 4 5module.exports = (on, config) => { 6 addMatchImageSnapshotPlugin(on, config); 7};
and in <rootDir>/cypress/support/commands.js
add:
1import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command'; 2 3addMatchImageSnapshotCommand();
1// addMatchImageSnapshotPlugin
2addMatchImageSnapshotPlugin(on, config);
3
4// addMatchImageSnapshotCommand
5addMatchImageSnapshotCommand();
6addMatchImageSnapshotCommand(commandName);
7addMatchImageSnapshotCommand(options);
8addMatchImageSnapshotCommand(commandName, options);
9
10// matchImageSnapshot
11.matchImageSnapshot();
12.matchImageSnapshot(name);
13.matchImageSnapshot(options);
14.matchImageSnapshot(name, options);
15
16// ---or---
17
18cy.matchImageSnapshot();
19cy.matchImageSnapshot(name);
20cy.matchImageSnapshot(options);
21cy.matchImageSnapshot(name, options);
1describe('Login', () => { 2 it('should be publicly accessible', () => { 3 cy.visit('/login'); 4 5 // snapshot name will be the test title 6 cy.matchImageSnapshot(); 7 8 // snapshot name will be the name passed in 9 cy.matchImageSnapshot('login'); 10 11 // options object passed in 12 cy.matchImageSnapshot(options); 13 14 // match element snapshot 15 cy.get('#login').matchImageSnapshot(); 16 }); 17});
Run Cypress with --env updateSnapshots=true
in order to update the base image files for all of your tests.
Run Cypress with --env failOnSnapshotDiff=false
in order to prevent test failures when an image diff does not pass.
Run Cypress with --reporter cypress-image-snapshot/reporter
in order to report snapshot diffs in your test results. This can be helpful to use with --env failOnSnapshotDiff=false
in order to quickly view all failing snapshots and their diffs.
If you using iTerm2, the reporter will output any image diffs right in your terminal 😎.
Similar use case to: https://github.com/cypress-io/cypress-example-docker-circle#spec--xml-reports
If you want to report snapshot diffs as well as generate XML junit reports, you can use mocha-multi-reporters.
npm install --save-dev mocha mocha-multi-reporters mocha-junit-reporter
You'll then want to set up a cypress-reporters.json
which may look a little like this:
1{ 2 "reporterEnabled": "spec, mocha-junit-reporter, cypress-image-snapshot/reporter", 3 "mochaJunitReporterReporterOptions": { 4 "mochaFile": "cypress/results/results-[hash].xml" 5 } 6}
where reporterEnabled
is a comma-separated list of reporters.
You can then run cypress like this:
cypress run --reporter mocha-multi-reporters --reporter-options configFile=cypress-reporters.json
or add the following to your cypress.json
{
..., //other options
"reporter": "mocha-multi-reporters",
"reporterOptions": {
"configFile": "cypress-reporters.json"
}
}
customSnapshotsDir
: Path to the directory that snapshot images will be written to, defaults to <rootDir>/cypress/snapshots
.customDiffDir
: Path to the directory that diff images will be written to, defaults to a sibling __diff_output__
directory alongside each snapshot.Additionally, any options for cy.screenshot()
and jest-image-snapshot can be passed in the options
argument to addMatchImageSnapshotCommand
and cy.matchImageSnapshot()
. The local options in cy.matchImageSnapshot()
will overwrite the default options set in addMatchImageSnapshot
.
For example, the default options we use in <rootDir>/cypress/support/commands.js
are:
1addMatchImageSnapshotCommand({
2 failureThreshold: 0.03, // threshold for entire image
3 failureThresholdType: 'percent', // percent of image or number of pixels
4 customDiffConfig: { threshold: 0.1 }, // threshold for each pixel
5 capture: 'viewport', // capture viewport in screenshot
6});
We really enjoy the diffing workflow of jest-image-snapshot and wanted to have a similar workflow when using Cypress. Because of this, under the hood we use some of jest-image-snapshot's internals and simply bind them to Cypress's commands and plugins APIs.
The workflow of cy.matchImageSnapshot()
when running Cypress is:
cy.screenshot()
named according to the current test.<rootDir>/cypress/snapshots
and if so diff against that snapshot.<rootDir>/cypress/snapshots/__diff_output__
.Cypress's screenshot functionality has changed significantly across 3.x.x
versions. In order to avoid buggy behavior, please use the following version ranges:
cypress-image-snapshot@>=1.0.0 <2.0.0
for cypress@>=3.0.0 <3.0.2
cypress-image-snapshot@>2.0.0
for cypress@>3.0.2
.No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 3/10 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
150 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More