Skip to content

Commit 01c66ee

Browse files
committed
document recomputeOnRetry, closes #304
1 parent 497d060 commit 01c66ee

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,37 @@ it('works 4', () => {
411411
412412
### recomputeOnRetry
413413
414-
Sometimes you want to enable test retries, but the data caching makes it hard to understand and run the full test. You can set the `recomputeOnRetry: true` to automatically call the `setup` again on tet retries.
414+
Sometimes you want to enable [test retries](https://on.cypress.io/test-retries), but the data caching makes it hard to understand and run the full test. You can set the `recomputeOnRetry: true` to automatically call the `setup` again on tet retries.
415+
416+
```js
417+
const dataSessionName = 'user v1'
418+
// 👎 instead of this way of clearing and recreating
419+
// the data session
420+
beforeEach(() => {
421+
// create new user if the test has failed
422+
// and now retries again
423+
if (Cypress.currentRetry) {
424+
Cypress.clearDataSession(dataSessionName)
425+
}
426+
})
427+
it('...', () => {
428+
cy.dataSession({
429+
name: dataSessionName,
430+
...
431+
})
432+
})
433+
434+
// 👍 you can simply use an option
435+
// to clear the saved session and set it up again
436+
// on test retry
437+
it('...', () => {
438+
cy.dataSession({
439+
name: dataSessionName,
440+
recomputeOnRetry: true,
441+
...
442+
})
443+
})
444+
```
415445
416446
## Flow
417447

0 commit comments

Comments
 (0)