-
Notifications
You must be signed in to change notification settings - Fork 659
/
index-test.js
71 lines (51 loc) · 1.62 KB
/
index-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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { Role, Selector, ClientFunction } from 'testcafe';
const page = 'http://localhost:3000/fixtures/reporter/pages/index.html';
fixture `Reporter`
.page `http://localhost:3000/fixtures/reporter/pages/index.html`;
const simpleRole1 = Role(page, () => {
}, { preserveUrl: true });
const complexRole = Role(page, async t => {
await t.click('#target');
});
const errorRole = Role(page, async t => {
await t.click(Selector('#non-existing-element'), { timeout: 100 });
});
const foo = ClientFunction(bool => () => bool);
test('Simple test', async t => {
await t.wait(1);
});
test('Simple command test', async t => {
await t.click(Selector('#target'));
});
test('Simple command err test', async t => {
await t.click('#non-existing-target');
});
test('Complex command test', async t => {
await t.useRole(simpleRole1);
});
test('Complex nested command test', async t => {
await t.useRole(complexRole);
});
test('Complex nested command error', async t => {
await t.useRole(errorRole);
});
test('Simple assertion', async t => {
await t.expect(true).eql(true, 'assertion message', { timeout: 100 });
});
test('Selector assertion', async t => {
await t.expect(Selector('#target').innerText).eql('target');
});
test('Snapshot', async () => {
await Selector('#target')();
await Selector('body').find('#target').innerText;
});
test('Client Function', async () => {
await foo(1, true);
});
test('Eval', async t => {
await t.eval(() => document.getElementById('#target'));
});
test('Screenshot on action error', async t => {
t.hover('body');
await t.click('#unexisting-element');
});