Installations
npm install match-screenshot
Releases
Unable to fetch releases
Developer
wix-incubator
Developer Guide
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Yes
Node Version
12.18.2
NPM Version
6.14.6
Statistics
14 Stars
60 Commits
7 Forks
7 Watching
20 Branches
8 Contributors
Updated on 15 Jul 2020
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
178,592
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
match-screenshot
A simple Jest or Chai matcher to compare screenshots, using Applitools Eyes (other platforms will be supported as well, TBD)
Install & Configure
Install Package
1npm install --save-dev match-screenshot
Setup eyes env variable
Add EYES_API_KEY
environment variable, with your eyes key
CI
Travis
go to your build's options -> settings -> Environment Variables
and add EYES_API_KEY
+ your key
locally
add an .env
file, with:
EYES_API_KEY=<your key here>
- this step is not mandatory - you should use it if you want to use eyes when running locally.
- ⚠️ you should put your
.env
file in git ignore!!!
Set the matcher
Jest
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');
Chai
1const {Assertion} = require('chai'); 2const toMatchScreenshot = require('match-screenshot/chai'); 3Assertion.addMethod('toMatchScreenshot', toMatchScreenshot);
Usage
Basic
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});
Creating a new baseline
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 });
API
toMatchScreenshot([options])
-
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 levelautoSaveNewTest
<[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});
jestWithConfig([options])
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
How does it work
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.
Typescript defintions
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
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
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
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 26 are checked with a SAST tool
Reason
54 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-4w2v-q235-vp99
- Warn: Project is vulnerable to: GHSA-cph5-m8f7-6c5x
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q
- Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44
- Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3
- Warn: Project is vulnerable to: GHSA-7wpw-2hjm-89gp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m / GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-g6ww-v8xp-vmwg
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9
- Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw
- Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc
- Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh
- Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
- Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp
Score
2.5
/10
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