Here’s the code sample from our tutorial on how to how to take a screenshot in Cypress

 

describe("Screenshot", () => {
beforeEach(() => cy.visit('/ingredients/file-picker'))
it('should take a screenshot', () => {
cy.screenshot();
});
it('should take a screenshot after trying to upload a picture', () => {
cy.get('#photo-upload').attachFile('images/french-toast.jpg');
cy.get('form figure').screenshot();
});
});
view raw screenshot.spec.js delivered with ❤ by emgithub

View on GitHub
Colby Fayock
Developer Advocate

Ready for the next generation of testing?

Get started today Schedule a demo