cypress-image-snapshot icon indicating copy to clipboard operation
cypress-image-snapshot copied to clipboard

Retry-ability

Open badeball opened this issue 5 years ago • 11 comments

Hi,

Retry-ability is a core feature of Cypress and part of what makes it so usable. Cypress also provides APIs to create custom commands that adhere to this pattern (using cy.should with functions, which is retried for you).

At my current project, we have some visual regression tests testing something with a very minor animation. We've successfully stored baseline images, but experience intermittent failures (0.3% - 0.5%) due to this animation.

I think it would be very cool for this library to do retry-ability, like we're all used to Cypress doing. I don't think it should be more than changing a .then with a .should, and using expect instead of throwing.

What do you think of this?

One challenge that does come to mind is when to store baseline images in scenarios with animations. This isn't however a new scenario, but something that is already difficult today as well.

badeball avatar Feb 10 '20 09:02 badeball

Since 1) cy.screenshot is not retried by itself and 2) requires post-processing before comparison, this isn't as simple as using should and expect. You need to create a custom command and utilize cy.verifyUpcomingAssertions, as shown here.

badeball avatar Feb 13 '20 08:02 badeball

a workaround to achieve the same result is

cy.get('LOCATOR`).should('be.visible').matchImageSnapshot(snapshotName);

0xIslamTaha avatar Feb 14 '20 15:02 0xIslamTaha

Hi @badeball would you mind reviewing this related issue? https://github.com/palmerhq/cypress-image-snapshot/issues/118

We can consolidate support to one or the other issue. Let me know which you prefer. I think this issue implies it is a new feature request while the other issue implies the current docs indicate this should already be possible.

Vandivier avatar Feb 21 '20 16:02 Vandivier

I don't have any strong preferences towards it.

Btw, I made a proof-of-concept of retry-ability here. Unforunately, I found the jest test to be highly coupled with implementation details and I'm hesitant in changing them (I think jest is the wrong way to test this and that acceptance tests in the form Cypress tests or tests writing tests is the only realistically good way of testing something like this).

badeball avatar Mar 06 '20 10:03 badeball

@badeball @Vandivier could u check this PR https://github.com/palmerhq/cypress-image-snapshot/pull/128 ?

0xIslamTaha avatar Apr 14 '20 09:04 0xIslamTaha

@0xIslamTaha peer review is done.

Vandivier avatar Apr 15 '20 23:04 Vandivier

Is there any progress on this? Or anything holding us back from implementing retry-ability?

ChristophWalter avatar Dec 03 '20 15:12 ChristophWalter

Is there any progress on this? Or anything holding us back from implementing retry-ability?

You could use my fork ✌️✌️

0xIslamTaha avatar Dec 04 '20 08:12 0xIslamTaha

Cypress v5+ has retries in it. We just need this PR to be merged as this library doesn't work with it yet :( https://github.com/jaredpalmer/cypress-image-snapshot/pull/155

lmeikle avatar Dec 04 '20 09:12 lmeikle

In cypress there are two concepts: Retry-ability and (lately) Test Retries. Both have their purpose. But I am with you @lmeikle, saw your PR before and it should be merged/reviewed... Is this library still maintained?

ChristophWalter avatar Dec 04 '20 11:12 ChristophWalter

I have been using this with patch-package for a while and it works just fine for me.

mauricedb avatar Dec 18 '20 13:12 mauricedb