i正在进行视觉回归,我在比较了同一URL但在不同环境中的两个屏幕截图。我正在从生产中获取屏幕截图,并将其与从测试Env中获取的快照进行比较。因此,任何人都可以告诉我如何在开始测试之前从上一个运行中删除所有存储的屏幕截图。我想在柏树默认值或选项中添加它,所以我不必每次手动执行
describe('Visual regression for elements in hotnews section', () => {
beforeEach(() => {
cy.viewport("macbook-15")
})
it('Take the screenshot of entire hot-news section in prod env', () => {
cy.visit("https://www.thequint.com/hot-news")
cy.get("#container").first().matchImageSnapshot('Hot-news',{coverage: 'fullpage'})
})
it('compare the screenshot of the hotnews section with the one taken in beta env', () => {
cy.visit('/hot-news',{failOnStatusCode: false})
cy.get("#container").matchImageSnapshot('Hot-news',{coverage: 'fullpage'})
})
})
我希望您必须在cypress.json
文件中设置选项"trashAssetsBeforeRuns": true
,该文件将在每次测试之前删除screenshotsFolder
和videosFolder
。
希望这会有所帮助。