小编Vin*_*rma的帖子

将现有屏幕截图与赛普拉斯中的实时应用程序进行比较时出现错误

如果我确实将屏幕截图与实时应用程序进行比较,那么它就会失败。最好的方法是什么以及如何比较 Cypress 中的屏幕截图

输出:在 cypress 上获取错误日志

在此输入图像描述

用于比较屏幕截图的已安装依赖项

npm install --save-dev cypress-image-snapshot @types/cypress-image-snapshot

Run Code Online (Sandbox Code Playgroud)
// code on commond.js file.
const compareSnapshotCommand = require('cypress-image-diff-js/dist/command')
compareSnapshotCommand();

 // code on cypress.config.json 
 const getCompareSnapshotsPlugin = require('cypress-image-diff-js/dist/plugin')
      getCompareSnapshotsPlugin(on, config)

// .js test scenario on test file 
describe('compare the homepage screen shot with the application homepage', () => {
    it('should compare the homepage', () => {
        cy.visit("/");
        cy.compareSnapshot('fixtures/healthcaresuccess-page.png', 0.001);
    }
Run Code Online (Sandbox Code Playgroud)

screenshot cypress

7
推荐指数
1
解决办法
853
查看次数

标签 统计

cypress ×1

screenshot ×1