cypress-plugin-snapshots icon indicating copy to clipboard operation
cypress-plugin-snapshots copied to clipboard

Add `overwrite` property to `toMatchSnapshot` to overwrite current snapshot

Open meinaart opened this issue 5 years ago • 2 comments

Add overwrite property to toMatchSnapshot to overwrite current snapshot. Makes it easier then doing it by hand.

meinaart avatar Jan 15 '19 17:01 meinaart

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();
});

ranbena avatar Mar 11 '19 20:03 ranbena

Implemented in commit 966dec9, you can now set the updateSnapshots flag on individual snapshots. e.g. cy.wrap(Date.now()).toMatchSnapshot({ updateSnapshots: true });

kmsauter avatar Oct 08 '19 11:10 kmsauter