File tree 1 file changed +49
-0
lines changed
1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,55 @@ test('when hidden: true logs available roles when it fails', () => {
53
53
` )
54
54
} )
55
55
56
+ test ( 'when hidden: logs elements with their names when it fails' , ( ) => {
57
+ const { getByRole} = render (
58
+ `<div><h1 hidden>Hi</h1><div hidden role="alertdialog" aria-label="My Dialog">Hello</div></div>` ,
59
+ )
60
+ expect ( ( ) => getByRole ( 'article' , { hidden : true } ) )
61
+ . toThrowErrorMatchingInlineSnapshot ( `
62
+ Unable to find an element with the role "article"
63
+
64
+ Here are the available roles:
65
+
66
+ heading:
67
+
68
+ Name "Hi":
69
+ <h1
70
+ hidden=""
71
+ />
72
+
73
+ --------------------------------------------------
74
+ alertdialog:
75
+
76
+ Name "My Dialog":
77
+ <div
78
+ aria-label="My Dialog"
79
+ hidden=""
80
+ role="alertdialog"
81
+ />
82
+
83
+ --------------------------------------------------
84
+
85
+ Ignored nodes: comments, script, style
86
+ <div>
87
+ <div>
88
+ <h1
89
+ hidden=""
90
+ >
91
+ Hi
92
+ </h1>
93
+ <div
94
+ aria-label="My Dialog"
95
+ hidden=""
96
+ role="alertdialog"
97
+ >
98
+ Hello
99
+ </div>
100
+ </div>
101
+ </div>
102
+ ` )
103
+ } )
104
+
56
105
test ( 'logs error when there are no accessible roles' , ( ) => {
57
106
const { getByRole} = render ( '<div />' )
58
107
expect ( ( ) => getByRole ( 'article' ) ) . toThrowErrorMatchingInlineSnapshot ( `
You can’t perform that action at this time.
0 commit comments