Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

add example with snapshots and test retries #363

Closed
wants to merge 1 commit into from

Conversation

bahmutov
Copy link
Contributor

Seems plugin https://github.com/meinaart/cypress-plugin-snapshots thinks every retry is just another snapshot in the same test, thus it fails.

const describeOrSkip = Cypress.getTestRetries ? describe : describe.skip
describeOrSkip('Retries', () => {
  it('work with snapshots', { retries: 2 }, () => {
    mount(<PositiveCounter />)
    cy.contains('Value: 0')

    // click the button the current number of retries
    const n = cy.state('test').currentRetry()
    Cypress._.times(n, () => {
      cy.get('.increment').click()
    })

    // make sure the component updates until it reaches counter 2
    cy.contains('Value:').toMatchHTML()
  })
})

where the snapshot was saved previously should be

exports[`Retries > work with snapshots #0`] =
{
  "html": "<span>Value: 2<button class=\"decrement\">−</button><button class=\"increment\">+</button></span>"
};

instead it retries (because the snapshot does not match) and then saves new snapshot

exports[`Retries > work with snapshots #1`] =
{
  "html": "<span>Value: 1<button class=\"decrement\">−</button><button class=\"increment\">+</button></span>"
};

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
topic: test retries ♵ Cypress test retries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant