-
Notifications
You must be signed in to change notification settings - Fork 11
/
spec.js
49 lines (45 loc) · 1.38 KB
/
spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// @ts-check
/// <reference types="cypress" />
import { recurse } from '../../../src'
// https://github.com/bahmutov/cypress-recurse/issues/26
// keeps clicking "Next" until the page has the element we are looking for
describe('find on page example', () => {
// because the test is random and can fail
// retry it a couple of times on CI
it('clicks until finds text', { retries: { runMode: 5 } }, () => {
cy.visit('cypress/e2e/find-on-page/index.html')
cy.contains('#output', 'Ready?').should('be.visible')
recurse(
() => cy.get('#output').invoke('text'),
// https://github.com/bahmutov/cypress-recurse/issues/76
// @ts-ignore
(text) => text === 'Surprise!',
{
delay: 500,
timeout: 60000,
log: false,
post: () => cy.get('[data-cy=next]').click(),
},
)
})
it(
'clicks until finds text (shorthand)',
{ retries: { runMode: 5 } },
() => {
cy.visit('cypress/e2e/find-on-page/index.html')
cy.contains('#output', 'Ready?').should('be.visible')
recurse(
() => cy.get('#output').invoke('text'),
// https://github.com/bahmutov/cypress-recurse/issues/76
// @ts-ignore
(text) => text === 'Surprise!',
{
delay: 500,
timeout: 60000,
log: false,
post: () => cy.get('[data-cy=next]').click(),
},
)
},
)
})