1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
7
+ < title > cypress-testing-library</ title >
8
+ < style >
9
+ blockquote {
10
+ margin : 0 ;
11
+ border-left : 4px solid grey;
12
+ padding-left : 10px ;
13
+ color : grey;
14
+ }
15
+ section {
16
+ padding : 10px ;
17
+ }
18
+ </ style >
19
+ </ head >
20
+ < body >
21
+ < blockquote >
22
+ No auto-reload after changing this static HTML markup:
23
+ click < span title ="Run All Tests "> ↻</ span > Run All Tests.
24
+ </ blockquote >
25
+ < section >
26
+ < h2 > getByPlaceholderText</ h2 >
27
+ < input type ="text " placeholder ="Placeholder Text " />
28
+ </ section >
29
+ < section >
30
+ < h2 > getByText</ h2 >
31
+ < button onclick ="this.innerText = 'Button Clicked' "> Button Text</ button >
32
+ < div id ="nested ">
33
+ < h3 > getByText within</ h3 >
34
+ < button onclick ="this.innerText = 'Button Clicked' "> Button Text</ button >
35
+ </ div >
36
+ </ section >
37
+ < section >
38
+ < h2 > getByLabelText</ h2 >
39
+ < label for ="input-labelled-by-id "> Label For Input Labelled By Id</ label >
40
+ < input type ="text " placeholder ="Input Labelled By Id " id ="input-labelled-by-id " />
41
+ </ section >
42
+ < section >
43
+ < h2 > getByAltText</ h2 >
44
+ < img
45
+ src ="data:image/png;base64, "
46
+ alt ="Image Alt Text "
47
+ onclick ="this.style.border = '5px solid red' "
48
+ />
49
+ </ section >
50
+ < section >
51
+ < h2 > getByTestId</ h2 >
52
+ < img
53
+ data-testid ="image-with-random-alt-tag "
54
+ src ="data:image/png;base64, "
55
+ onclick ="this.style.border = '5px solid red' "
56
+ />
57
+ </ section >
58
+ < section >
59
+ < h2 > getAllByText</ h2 >
60
+ < button onclick ="this.innerText = 'Jackie Kicked' "> Jackie Chan 1</ button >
61
+ < button onclick ="this.innerText = 'Jackie Kicked' "> Jackie Chan 2</ button >
62
+ </ section >
63
+ <!-- Prettier unindents the script tag below -->
64
+ < script >
65
+ document
66
+ . querySelector ( '[data-testid="image-with-random-alt-tag"]' )
67
+ . setAttribute ( 'alt' , 'Image Random Alt Text ' + Math . random ( ) )
68
+ </ script >
69
+ </ body >
70
+ </ html >
0 commit comments