Test Overview
This test checks if the homepage looks the same as before by taking a screenshot and comparing it to a saved image. It helps find unexpected visual changes.
This test checks if the homepage looks the same as before by taking a screenshot and comparing it to a saved image. It helps find unexpected visual changes.
describe('Visual Regression Test for Homepage', () => { it('should match the baseline screenshot', () => { cy.visit('https://example.com') cy.get('header').should('be.visible') cy.matchImageSnapshot('homepage') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initialized, ready to run the visual regression test | - | PASS |
| 2 | Browser opens and navigates to 'https://example.com' | Homepage loads fully with header visible | Page loaded successfully | PASS |
| 3 | Finds the header element on the page | Header element is present and visible | cy.get('header').should('be.visible') verifies header is visible | PASS |
| 4 | Takes a screenshot and compares it to the baseline image named 'homepage' | Screenshot captured and compared to saved baseline | cy.matchImageSnapshot('homepage') checks for visual differences | PASS |
| 5 | Test ends with visual comparison result | No visual differences found | Visual snapshot matches baseline | PASS |