Skip to content

Instantly share code, notes, and snippets.

@ygerasimov
Created March 15, 2025 13:28
Show Gist options
  • Save ygerasimov/c9802156724a8d4a7f3960745f7a119a to your computer and use it in GitHub Desktop.
Save ygerasimov/c9802156724a8d4a7f3960745f7a119a to your computer and use it in GitHub Desktop.
const baseUrl = 'https://www.adaptive.co.uk';
const pages = ['/', '/contact-us'];
const breakpoints = [640, 1200];
describe('Sauce Visual Demo', () => {
it('should be able to open the pages and take screenshots', () => {
pages.forEach((page) => {
breakpoints.forEach((breakpoint) => {
let fullUrl = baseUrl + page;
cy.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from failing the test
return false
})
cy.visit(fullUrl);
cy.viewport(breakpoint, 1000);
// Modify the page before taking screenshots.
cy.get('body').then(($body) => {
if ($body.find('#CybotCookiebotDialogBodyButtonDecline').length) {
cy.get('#CybotCookiebotDialogBodyButtonDecline').click();
}
});
cy.sauceVisualCheck(fullUrl + ' ' + page, {
captureDom: true
})
});
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment