Skip to content

Instantly share code, notes, and snippets.

@aleccool213
Created December 16, 2019 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aleccool213/e0445d07bdab874cea06eb96284d2661 to your computer and use it in GitHub Desktop.
Save aleccool213/e0445d07bdab874cea06eb96284d2661 to your computer and use it in GitHub Desktop.
/**
* 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