cypress-plugin-snapshots
cypress-plugin-snapshots copied to clipboard
Add `overwrite` property to `toMatchSnapshot` to overwrite current snapshot
Add overwrite
property to toMatchSnapshot
to overwrite current snapshot. Makes it easier then doing it by hand.
Thisi my use case for this feature:
it('cancel button returns to original state', () => {
// save current state
cy.get('some-element').toMatchSnapshot({
overwrite: true,
});
// do stuff
// click cancel
// compare to original state
cy.get('some-element').toMatchSnapshot();
});
Implemented in commit 966dec9, you can now set the updateSnapshots flag on individual snapshots.
e.g. cy.wrap(Date.now()).toMatchSnapshot({ updateSnapshots: true });