All Projects → julianburr → Cypress Match Screenshot

julianburr / Cypress Match Screenshot

Licence: mit
Utility to take screenshots during a cypress test and match them against previous runs

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Cypress Match Screenshot

screenshotgun
Open cross-platform screenshoter with cloud support and server part
Stars: ✭ 23 (-62.3%)
Mutual labels:  screenshots
Capture Website Cli
Capture screenshots of websites from the command-line
Stars: ✭ 545 (+793.44%)
Mutual labels:  screenshots
Fastlane
🚀 The easiest way to automate building and releasing your iOS and Android apps
Stars: ✭ 33,382 (+54624.59%)
Mutual labels:  screenshots
freeshooter
This is old-school tool for taking screenshots without bloatware features, simple as life, light as air.
Stars: ✭ 102 (+67.21%)
Mutual labels:  screenshots
Falcon
Take Android screenshots with Falcons bright eye!
Stars: ✭ 362 (+493.44%)
Mutual labels:  screenshots
Manet
Website screenshot service powered by Node.js, SlimerJS and PhantomJS
Stars: ✭ 570 (+834.43%)
Mutual labels:  screenshots
dots
🌀 my linux configuration
Stars: ✭ 66 (+8.2%)
Mutual labels:  screenshots
Screenshooter
📷 A tool for generating BrowserStack screenshots from the command line.
Stars: ✭ 50 (-18.03%)
Mutual labels:  screenshots
Witnessme
Web Inventory tool, takes screenshots of webpages using Pyppeteer (headless Chrome/Chromium) and provides some extra bells & whistles to make life easier.
Stars: ✭ 436 (+614.75%)
Mutual labels:  screenshots
Snapshots For Windows
Application for make and upload screenshots / Приложение для создания и загрузки скриншотов
Stars: ✭ 6 (-90.16%)
Mutual labels:  screenshots
TACTIC-Handler
PySide based TACTIC client for maya, nuke, 3dsmax, houdini, etc
Stars: ✭ 67 (+9.84%)
Mutual labels:  screenshots
Screen capture lite
cross platform screen/window capturing library
Stars: ✭ 340 (+457.38%)
Mutual labels:  screenshots
Androidscreenshot sysapi
Easily take screenshots with Android 5.0 API.{优雅地实现屏幕截图,用android 5.0之后的录屏API实现}
Stars: ✭ 644 (+955.74%)
Mutual labels:  screenshots
urlbox-screenshots-node
Capture website thumbnails using the urlbox.io screenshot as a service API in node
Stars: ✭ 14 (-77.05%)
Mutual labels:  screenshots
Gowitness
🔍 gowitness - a golang, web screenshot utility using Chrome Headless
Stars: ✭ 996 (+1532.79%)
Mutual labels:  screenshots
facebook-3d-photo-unity
Unity extension to take 3D screenshots for Facebook
Stars: ✭ 24 (-60.66%)
Mutual labels:  screenshots
Jvedio
Windows desktop application to manage local video;Support baidu AI, youdao translation;Support FFMPEG video processing;Support multi-database management and statistics;Support skin switching
Stars: ✭ 545 (+793.44%)
Mutual labels:  screenshots
Capture Website
Capture screenshots of websites
Stars: ✭ 1,075 (+1662.3%)
Mutual labels:  screenshots
Chart To Aws
Microservice to generate screenshot from a webpage and upload it to a AWS S3 Bucket.
Stars: ✭ 43 (-29.51%)
Mutual labels:  screenshots
Tysnapshotscroll
一句代码保存截图,将 UIScrollView UITableView UICollectionView UIWebView WKWebView 网页 保存 为 长图 查看。Save the scroll view page as an image,support UIScrollView,UITableView,UICollectionView,UIWebView,WKWebView.(Support iOS13)
Stars: ✭ 709 (+1062.3%)
Mutual labels:  screenshots

cypress-match-screenshot

npm version

Utility to take screenshots during a cypress test and match them against previous runs.

Disclaimer

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 😄

Usage

yarn add cypress-match-screenshot --dev

Then register the custom command in your cypress/support/commands.js file:

import { register } from 'cypress-match-screenshot';
register();

That's it, now you can use the feature like this:

describe('Example', function () {
  it('Should match screenshot', function () {
    cy.visit('https://google.com');
    cy.matchScreenshot('Google Screenshot');
  });
});

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 😊

CI

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:

{
  "trashAssetsBeforeHeadlessRuns": false
}

API

register

name (optional)

You can optionally define the name you want the functionality to be registered on. By default its matchScreenshot.

import { register } from 'cypress-match-screenshot'
register('myCustomName');

// then in the test
cy.myCustomName('Example');

Match screenshot method

cy.matchScreenshot(name, {
  threshold,
  thresholdType
});

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

  • threshold: Threshold for the screenshot matching, default: 0.005
  • thresholdType: unit for the threshold,pixel or percent, default: percent

Update screenshots

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.

Todos

  • [x] Crop screenshots to only contain relevant viewport (see https://github.com/cypress-io/cypress/issues/1810)
  • [x] See if we can add more meaningful assertion messages
  • [ ] Somehow show the diff image whenever the check fails
  • [ ] Test and verify CI behaviour of this plugin
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].