Chapter 8 - Visual Validation in Cypress
Steps
- Create Applitools account
- Find API key in Applitools account
- Create environment variable holding API key. Eyes plagun will automatically use it.
- Install plugin
npm install @applitools/eyeys-cypress@3
- Run
npx eyes-setup
to set up eyes plugin. - Write test that uses eys plugin for visual testing
- Run tests 1st time
- Check results in Aplitools account -
New
status - Run tests 2nd time
- Check results in Aplitools account - Passed status
- Add browser section in the test
Sample code
/// <reference types="cypress" />
import * as todoPage from '../page-objects/todo-page'
describe('visual validation', () => {
before(() => cy.visit('http://todomvc-app-for-testing.surge.sh/?different-title-color'))
beforeEach(() =>
cy.eyesOpen({
appName: 'TAU TodoMVC',
batchName: 'TAU TodoMVC',
browser: [
{name: 'chrome', width: 1024, height: 768},
{name: 'chrome', width: 800, height: 600},
{name: 'firefox', width: 1024, height: 768},
{deviceName: 'iPhone X'},
]
})
)
afterEach(() => cy.eyesClose())
it('should look good', () => {
cy.eyesCheckWindow('empty todo list')
todoPage.addTodo('Clean room')
todoPage.addTodo('Learn javascript')
cy.eyesCheckWindow('two todos')
todoPage.toggleTodo(0)
cy.eyesCheckWindow('mark as completed')
})
})