You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(debug): Adding debug log when a get call fails (#3)
* feat(debug_helper): Adding debug helper when a get call fails
* fix(review): Few minor changes
* moving pretty-format to the dep
* fix(review_comments): Making the fixes mentioned in the review comments
* Update README.md
* Update element-queries.js
Unable to find an element with the text: Goodbye world. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
exports[`get throws a useful error message 1`] =`"Unable to find a label with the text of: LucyRicardo"`;
3
+
exports[`get throws a useful error message 1`] =`
4
+
"Unable to find a label with the text of: LucyRicardo
4
5
5
-
exports[`get throws a useful error message 2`] =`"Unable to find an element with the placeholder text of: LucyRicardo"`;
6
+
[36m<div>[39m
7
+
[36m<div />[39m
8
+
[36m</div>[39m"
9
+
`;
6
10
7
-
exports[`get throws a useful error message 3`] =`"Unable to find an element with the text: LucyRicardo. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible."`;
11
+
exports[`get throws a useful error message 2`] =`
12
+
"Unable to find an element with the placeholder text of: LucyRicardo
8
13
9
-
exports[`get throws a useful error message 4`] =`"Unable to find an element by: [data-testid=\\"LucyRicardo\\"]"`;
14
+
[36m<div>[39m
15
+
[36m<div />[39m
16
+
[36m</div>[39m"
17
+
`;
10
18
11
-
exports[`get throws a useful error message 5`] =`"Unable to find an element with the alt text: LucyRicardo"`;
19
+
exports[`get throws a useful error message 3`] =`
20
+
"Unable to find an element with the text: LucyRicardo. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.
12
21
13
-
exports[`label with no form control 1`] =`"Found a label with the text of: alone, however no form control was found associated to that label. Make sure you're using the \\"for\\" attribute or \\"aria-labelledby\\" attribute correctly."`;
22
+
[36m<div>[39m
23
+
[36m<div />[39m
24
+
[36m</div>[39m"
25
+
`;
14
26
15
-
exports[`totally empty label 1`] =`"Found a label with the text of: , however no form control was found associated to that label. Make sure you're using the \\"for\\" attribute or \\"aria-labelledby\\" attribute correctly."`;
27
+
exports[`get throws a useful error message 4`] =`
28
+
"Unable to find an element by: [data-testid=\\"LucyRicardo\\"]
29
+
30
+
[36m<div>[39m
31
+
[36m<div />[39m
32
+
[36m</div>[39m"
33
+
`;
34
+
35
+
exports[`get throws a useful error message 5`] =`
36
+
"Unable to find an element with the alt text: LucyRicardo
37
+
38
+
[36m<div>[39m
39
+
[36m<div />[39m
40
+
[36m</div>[39m"
41
+
`;
42
+
43
+
exports[`label with no form control 1`] =`
44
+
"Found a label with the text of: alone, however no form control was found associated to that label. Make sure you're using the \\"for\\" attribute or \\"aria-labelledby\\" attribute correctly.
45
+
46
+
[36m<div>[39m
47
+
[36m<label>[39m
48
+
[0mAll alone[0m
49
+
[36m</label>[39m
50
+
[36m</div>[39m"
51
+
`;
52
+
53
+
exports[`totally empty label 1`] =`
54
+
"Found a label with the text of: , however no form control was found associated to that label. Make sure you're using the \\"for\\" attribute or \\"aria-labelledby\\" attribute correctly.
`Unable to find an element with the placeholder text of: ${text}`,
97
+
`Unable to find an element with the placeholder text of: ${text} \n\n${htmlElementToDisplay(
98
+
container,
99
+
)}`,
91
100
)
92
101
}
93
102
returnel
@@ -99,10 +108,16 @@ function getByLabelText(container, text, ...rest) {
99
108
constlabel=queryLabelByText(container,text)
100
109
if(label){
101
110
thrownewError(
102
-
`Found a label with the text of: ${text}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly.`,
111
+
`Found a label with the text of: ${text}, however no form control was found associated to that label. Make sure you're using the "for" attribute or "aria-labelledby" attribute correctly. \n\n${htmlElementToDisplay(
112
+
container,
113
+
)}`,
103
114
)
104
115
}else{
105
-
thrownewError(`Unable to find a label with the text of: ${text}`)
116
+
thrownewError(
117
+
`Unable to find a label with the text of: ${text} \n\n${htmlElementToDisplay(
118
+
container,
119
+
)}`,
120
+
)
106
121
}
107
122
}
108
123
returnel
@@ -112,7 +127,9 @@ function getByText(container, text, ...rest) {
112
127
constel=queryByText(container,text, ...rest)
113
128
if(!el){
114
129
thrownewError(
115
-
`Unable to find an element with the text: ${text}. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.`,
130
+
`Unable to find an element with the text: ${text}. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible. \n\n${htmlElementToDisplay(
131
+
container,
132
+
)}`,
116
133
)
117
134
}
118
135
returnel
@@ -129,11 +146,27 @@ function queryByAltText(container, alt) {
129
146
functiongetByAltText(container,alt){
130
147
constel=queryByAltText(container,alt)
131
148
if(!el){
132
-
thrownewError(`Unable to find an element with the alt text: ${alt}`)
149
+
thrownewError(
150
+
`Unable to find an element with the alt text: ${alt} \n\n${htmlElementToDisplay(
0 commit comments