meinaart / cypress-plugin-snapshots

Plugin for snapshot tests in Cypress.io
MIT License
491 stars 116 forks source link

(feat) make compatible with cypress-plugin-retries #127

Open gnicol opened 4 years ago

gnicol commented 4 years ago

Is your feature request related to a problem? Please describe. Rarely, I have a test failure (not due to your great plugin!) and using cypress-plugin-retries would be helpful (though I realize not best practice).

Presently, I cannot use that as the incrementing SNAPSHOTS_TEXT/SNAPSHOTS_IMAGE will continue to increment on re-runs of a given test causing the asserts to not line up.

Code located here https://github.com/meinaart/cypress-plugin-snapshots/blob/cf07698779b40f1735cc1486cb3aa9fdcadd1f7d/src/utils/snapshotTitles.js#L3-L4

Describe the solution you'd like Two possible solutions jump to mind:

1) Allow count to be reset I was wondering if you could expose a resetCount() method in the snapshotTitles.js that simply blanks the SNAPSHOTS_TEXT/SNAPSHOTS_IMAGE entry for the active test? Then I could call that in my beforeEach to ensure retries worked (assuming the test name is correctly identifiable in beforeEach).

2) Allow full snapshot title to be specified I considered setting a more hard-coded snapshot name on each call so they would align during retries. But at present, I seem unable to exclude the count const snapshotTitle = `${testTitle} #${snapshots[testTitle]}`; If it was possible to specify a title template, or to specify the desired title with a flag to indicate it ought to be used verbatim; retries would line up and that would work as well.

Describe alternatives you've considered Forking, and likely just going the drop count from title approach. But I'd very much prefer not to :(

Additional context Highly open to other approaches/ideas though! Given some direction I'd try to push up a PR as well if that helped.

azuruce commented 3 years ago

yes, I had a problem as our test sometimes failed and we want to retry. It could be failed for variety of reasons such as a dependency service has slightly flakiness or database lock contention.

kuceb commented 3 years ago

see #141 for support for native test retries in 5.0