Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* Takes a snapshot of the application at the moment this method is called.
*
* When running in headless mode, it takes a snapshot with Percy, which is
* useful for testing purposes when integrated with our CI process.
*
* When running in headed mode, it takes a Cypress screenshot instead,
* which is more useful for allowing a developer to see a preview.
*
* @param description A string that describes the snapshot.
*/
export const takeSnapshot = (description?: string) => {
if (Cypress.browser.isHeaded) {
return cy.screenshot();
}
return cy.percySnapshot(description);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.