-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathselectors.ts
More file actions
76 lines (62 loc) · 1.82 KB
/
Copy pathselectors.ts
File metadata and controls
76 lines (62 loc) · 1.82 KB
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
72
73
74
75
76
/* eslint-disable testing-library/prefer-screen-queries */
import {
getByText,
getByPlaceholderText,
getByLabelText,
getByAltText,
getByTestId,
getAllByText,
queryByText,
queryAllByText,
findByText,
} from "../../src/";
fixture`selectors`.page`../../test-app/index.html`;
test("getByPlaceHolderText", async (t) => {
await t.typeText(
getByPlaceholderText("Placeholder Text"),
"Hello Placeholder"
);
});
test("getByText", async (t) => {
await t.click(getByText("getByText"));
});
test("queryByText with timeout as property", async (t) => {
await t.click(queryByText("Late content!").with({ timeout: 20000 }));
});
test("getByLabelText", async (t) => {
await t.typeText(
getByLabelText("Label For Input Labelled By Id"),
"Hello Input Labelled By Id"
);
});
test("getByAltText", async (t) => {
await t.click(getByAltText("Image Alt Text"));
});
test("getByTestId", async (t) => {
await t.click(getByTestId("image-with-random-alt-tag"));
});
test("getAllByText", async (t) => {
const chans = getAllByText(/^Jackie Chan/);
const count = await chans.count;
await t.expect(count).eql(2);
await t.click(chans.nth(1));
await t.click(chans.nth(0));
});
test("queryAllByText", async (t) => {
await t.expect(queryAllByText("Button Text").exists).ok();
await t.expect(queryAllByText("Non-existing Button Text").exists).notOk();
});
test("findByText async", async (t) => {
await t.click(getByText("delayed"));
await t.expect(findByText("updated button async").exists).ok();
});
test("still works after browser page load", async (t) => {
await t
.click(getByText("Go to Page 2"))
.expect(getByText("second page").exists)
.ok();
});
test("still works after reload", async (t) => {
await t.eval(() => location.reload());
await t.expect(getByText("getByText").exists).ok();
});