Created
August 1, 2024 13:20
-
-
Save adamliptrot-oc/71c4d7fd2af8141e83e83d4b4ac3039f to your computer and use it in GitHub Desktop.
Visual regression testing with Cypress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const baseUrl = "https://liptrot.org"; | |
| const sizes = [[600, 900]] | |
| const pages = [ | |
| {url:"/",name:"home"}, | |
| {url: "/guides", name:"guides"}, | |
| {url: "/posts/accessible-names/", name:"blog-accessible-names"} | |
| ] | |
| sizes.forEach((size) => { | |
| describe(`On ${size} screen`, () => { | |
| pages.forEach((page) => { | |
| it(`Render ${page.name}`, () => { | |
| if (Cypress._.isArray(size)) { | |
| cy.viewport(size[0], size[1]) | |
| } else { | |
| cy.viewport(size) | |
| } | |
| cy.visit(siteUrl + page.url) | |
| cy.compareSnapshot(`${page.name}-${size}`) | |
| }) | |
| }) | |
| }) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment