jaredpalmer/cypress-image-snapshot — dự án mã nguồn mở — đang có 890 sao GitHub. Catch visual regressions in Cypress
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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.
See it in action!
Cypress GUI
When using cypress open, errors are displayed in the GUI.
Composite Image Diff
When an image diff fails, a composite image is constructed.
Test Reporter
When using cypress run and --reporter cypress-image-snapshot/reporter, diffs are output to your terminal.
Installation
Install from npm
npm install --save-dev cypress-image-snapshot
then add the following in your project's <rootDir>/cypress/plugins/index.js:
describe('Login', () => {
it('should be publicly accessible', () => {
cy.visit('/login');
// snapshot name will be the test title
cy.matchImageSnapshot();
// snapshot name will be the name passed in
cy.matchImageSnapshot('login');
// options object passed in
cy.matchImageSnapshot(options);
// match element snapshot
cy.get('#login').matchImageSnapshot();
});
});
Updating snapshots
Run Cypress with --env updateSnapshots=true in order to update the base image files for all of your tests.
Preventing failures
Run Cypress with --env failOnSnapshotDiff=false in order to prevent test failures when an image diff does not pass.
Reporter
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 😎.
Multiple reporters
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.
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:
addMatchImageSnapshotCommand({
failureThreshold: 0.03, // threshold for entire image
failureThresholdType: 'percent', // percent of image or number of pixels
customDiffConfig: { threshold: 0.1 }, // threshold for each pixel
capture: 'viewport', // capture viewport in screenshot
});
How it works
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:
Take a screenshot with cy.screenshot() named according to the current test.
Check if a saved snapshot exists in <rootDir>/cypress/snapshots and if so diff against that snapshot.
If there is a resulting diff, save it to <rootDir>/cypress/snapshots/__diff_output__.
Cypress Version Requirements
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
Đọc thêm về jaredpalmer/cypress-image-snapshot ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/jaredpalmer/cypress-image-snapshot là nguồn chính thức.
jaredpalmer/cypress-image-snapshot có phải mã nguồn mở không?
Có — jaredpalmer/cypress-image-snapshot phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/jaredpalmer/cypress-image-snapshot.
jaredpalmer/cypress-image-snapshot có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho jaredpalmer/cypress-image-snapshot. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
jaredpalmer/cypress-image-snapshot dùng license gì?
jaredpalmer/cypress-image-snapshot phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
jaredpalmer/cypress-image-snapshot là gì?
jaredpalmer/cypress-image-snapshot (jaredpalmer/cypress-image-snapshot) là dự án JavaScript trên GitHub. Theo mô tả gốc: Catch visual regressions in Cypress
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về cypress-image-snapshot?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về cypress-image-snapshot.