-
-
Notifications
You must be signed in to change notification settings - Fork 737
/
Copy pathretryTo_test.js
36 lines (30 loc) · 1004 Bytes
/
retryTo_test.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
const { I } = inject();
Feature('Plugins');
Scenario('retryTo works with await steps @plugin', async () => {
await retryTo(async (tryNum) => {
const foo = await I.grabCurrentUrl();
if (tryNum < 3) I.waitForVisible('.nothing', 1);
}, 4);
});
Scenario('retryTo works with non await steps @plugin', async () => {
await retryTo(async (tryNum) => {
if (tryNum < 3) I.waitForVisible('.nothing', 1);
}, 4);
});
Scenario('Should be succeed', async ({ I }) => {
I.amOnPage('http://example.org');
I.waitForVisible('.nothing', 1); // should fail here but it won't terminate
await retryTo((tryNum) => {
I.see('.doesNotMatter');
}, 10);
});
Scenario('Should fail after reached max retries', async () => {
await retryTo(() => {
throw new Error('Custom pluginRetryTo Error');
}, 3);
});
Scenario('Should succeed at the third attempt @plugin', async () => {
await retryTo(async (tryNum) => {
if (tryNum < 2) throw new Error('Custom pluginRetryTo Error');
}, 3);
});