29. it('should screenshot', () => {
…
// Takes snapshot of page
cy.track('Image name’);
// Snapshot of one element
cy.get('#element')
.track('Image name')
// Spoiler alert: It’s the
// same with Percy
…
});
37. const now = new Date(2018, 1, 1)
.getTime();
// freezes the system time to Jan 1, 2018
cy.clock(now);
// continue with your normal tests below
38.
39.
40. // Wait for loading times
cy.get('.grid-selection‘)
.should('not.exist');
cy.get('.sw-loader')
.should('not.exist');
41.
42.
43.
44. // An own Command
Cypress.Commands.add('changeElementStyling', (selector, imageStyle) => {
// E.g. replace the image with a fixed one
cy.get(selector)
.invoke('attr', 'style', imageStyle)
.should('have.attr', 'style', imageStyle);
});