Gathering detailed insights and metrics for match-screenshot
Gathering detailed insights and metrics for match-screenshot
Gathering detailed insights and metrics for match-screenshot
Gathering detailed insights and metrics for match-screenshot
npm install match-screenshot
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
14 Stars
60 Commits
7 Forks
7 Watching
20 Branches
8 Contributors
Updated on 15 Jul 2020
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-75%
1
Compared to previous day
Last week
1,744%
461
Compared to previous week
Last month
631.4%
512
Compared to previous month
Last year
-13.7%
10,644
Compared to previous year
A simple Jest or Chai matcher to compare screenshots, using Applitools Eyes (other platforms will be supported as well, TBD)
1npm install --save-dev match-screenshot
Add EYES_API_KEY
environment variable, with your eyes key
go to your build's options -> settings -> Environment Variables
and add EYES_API_KEY
+ your key
add an .env
file, with:
EYES_API_KEY=<your key here>
.env
file in git ignore!!!1"jest": { 2 "setupTestFrameworkScriptFile": "match-screenshot/jest" 3}
In case you have several custom matchers in your project / you need setupTestFrameworkScriptFile
for other configurations, just use:
1"jest": { 2 "setupTestFrameworkScriptFile": "<rootDir>/setupTestFrameworkScriptFile.js" 3}
Inside setupTestFrameworkScriptFile.js
you can then:
1require('match-screenshot/jest');
1const {Assertion} = require('chai'); 2const toMatchScreenshot = require('match-screenshot/chai'); 3Assertion.addMethod('toMatchScreenshot', toMatchScreenshot);
Puppeteer example:
1it('my test', async () { 2 await page.goto('http://www.wix.com'); 3 const screenshot = await page.screenshot(); 4 await expect(screenshot).toMatchScreenshot({key: 'my test'}); 5});
When you change production code implementation, Eyes will break, and you will have to go to its management Dashboard and approve the change. In order to avoid that, you can assign a new version and create a new baseline:
1 it('my test', async () { 2 await page.goto('http://www.wix.com'); 3 const screenshot = await page.screenshot(); 4 await expect(screenshot).toMatchScreenshot({key: 'my test', version: 'v1.0.1'}); 5 });
options
key
<[string]> A unique key for your screenshot. This key will be used in Applittols Eyes.
version
<[string]> (optional) Used to create a new baseline. See Creating a new baseline for more details. Default value: 'v1.0.0'.
viewport
<[string]> (optional) Explicitly pass viewport argument to Applitools api. This will prevent Applitools from creating a new baseline in case of a change in the screenshot actual viewport. Instead, it will fail the test.
matchLevel
<[enum]> (optional) Explicitly set match level
autoSaveNewTest
<[boolean]> (optional) If you set it to false, every time that eyes will detect a new test(different viewport size, first run) it will fail the test and the baseline will need to be approved in Eyes. Default value: true.
1const MatchLevel = require('match-screenshot/matchLevel')
2...
3await expect(screenshot).toMatchScreenshot({key: 'my test', matchLevel: MatchLevel.Explicit});
Configure your matcher with global options.
Set the matcher:
1"jest": { 2 "setupTestFrameworkScriptFile": "<rootDir>/setupTestFrameworkScriptFile.js" 3},
Inside setupTestFrameworkScriptFile.js
you can then:
1require('match-screenshot/jestWithConfig')(options);
options
appName
<[string]> Application name. Will be used inside Applitools as part of test title
Everytime you use toMatchScreenshot
matcher, a screenshot will be sent to Applitools Eyes, which will compare the new screenshot with the baseline. The test will fail if they are not equal.
If you are using typescript and are missing type defintions for toMatchScreenshot
, you can add the following line to your tsconfig:
1 "files": [ 2 "./node_modules/match-screenshot/index.d.ts", 3 ]
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 9/30 approved changesets -- score normalized to 3
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
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
54 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
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