Gathering detailed insights and metrics for cypress-match-screenshot
Gathering detailed insights and metrics for cypress-match-screenshot
Gathering detailed insights and metrics for cypress-match-screenshot
Gathering detailed insights and metrics for cypress-match-screenshot
Utility to take screenshots during a cypress test and match them against previous runs
npm install cypress-match-screenshot
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
58 Stars
30 Commits
19 Forks
5 Watchers
1 Branches
4 Contributors
Updated on Apr 16, 2023
Latest Version
1.1.0
Package Id
cypress-match-screenshot@1.1.0
Unpacked Size
41.00 kB
Size
14.15 kB
File Count
7
NPM Version
6.4.0
Node Version
9.11.2
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
5
Utility to take screenshots during a cypress test and match them against previous runs.
Cypress is actively working on a feature like this, see https://github.com/cypress-io/cypress/issues/495. With that in mind this package should only be seen as temporary solution until Cypress publishes their official solution … but if you're like me and want to do some screenshot matching rather sooner than later, feel free to give it a shot 😄
1yarn add cypress-match-screenshot --dev
Then register the custom command in your cypress/support/commands.js
file:
1import { register } from 'cypress-match-screenshot'; 2register();
That's it, now you can use the feature like this:
1describe('Example', function () { 2 it('Should match screenshot', function () { 3 cy.visit('https://google.com'); 4 cy.matchScreenshot('Google Screenshot'); 5 }); 6});
On the first run the assertion will always pass and the tool will just store the screenshot. On subsequent runs it will take a screenshot and compare it to the previous one. Only if the difference is below the threshold the assertion will pass and the old screenshot will be replaced by the new one.
You can find all diffs as images in cypress/screenshots/diff
to see what excactly changed 😊
NOTE: I haven't played around with screenshot matching in CI, so treat everything in here careful and please feel free to add / edit anything if you find missing or wrong information 😊
Keep screenshots around to be matched
By default Cypress deletes all the screenshots before running tests in CI mode. To disable that (to keep the screenshots around so they can be matched in subsequent runs) just add the following to your cypress.json
config:
1{ 2 "trashAssetsBeforeHeadlessRuns": false 3}
name (optional)
You can optionally define the name you want the functionality to be registered on. By default its matchScreenshot
.
1import { register } from 'cypress-match-screenshot' 2register('myCustomName'); 3 4// then in the test 5cy.myCustomName('Example');
1cy.matchScreenshot(name, {
2 threshold,
3 thresholdType
4});
name
If you have multiple screenshots within the same test case, you need to give them unique names so that the matcher can identify which image it should match to. It also makes it easier for you to find the image in the screenshots
folder.
The general rule for screenshot naming is: [Test Suit Name] -- [Test Name] -- [Screenshot Name].png
options
0.005
pixel
or percent
, default: percent
If you want to update the base screenshots with the new generated set, put the updateScreenshots
parameter to your Cypress config. This will allow your tests to pass and the base screenshots being replaced by the new ones.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 5/24 approved changesets -- score normalized to 2
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
28 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