@@ -51,6 +51,10 @@ const valid = [
51
51
expect(foo).not.toHaveLength(0)` ,
52
52
`let foo;
53
53
expect(foo).toHaveLength(1);` ,
54
+ `let foo;
55
+ expect(foo).toHaveLength()` ,
56
+ `let foo;
57
+ expect(foo).toHaveLength(1, 2, 3)` ,
54
58
`expect(screen.notAQuery('foo-bar')).toHaveLength(1)` ,
55
59
`expect(screen.getAllByText('foo-bar')).toHaveLength(2)` ,
56
60
`import foo from "./foo";
@@ -99,6 +103,82 @@ const valid = [
99
103
expect(element).toBeInTheDocument` ,
100
104
] ;
101
105
const invalid = [
106
+ invalidCase (
107
+ `expect(screen.getByText('foo')).toHaveLength()` ,
108
+ `expect(screen.getByText('foo')).not.toBeInTheDocument()`
109
+ ) ,
110
+ invalidCase (
111
+ `expect(screen.getAllByText('foo')).toHaveLength()` ,
112
+ `expect(screen.getByText('foo')).not.toBeInTheDocument()`
113
+ ) ,
114
+ invalidCase (
115
+ `expect(screen.getByRole('foo')).toHaveLength()` ,
116
+ `expect(screen.getByRole('foo')).not.toBeInTheDocument()`
117
+ ) ,
118
+ invalidCase (
119
+ `expect(screen.getAllByRole('foo')).toHaveLength()` ,
120
+ `expect(screen.getByRole('foo')).not.toBeInTheDocument()`
121
+ ) ,
122
+ invalidCase (
123
+ `expect(screen.getByRole('foo')).toHaveLength(0,2,3)` ,
124
+ `expect(screen.getByRole('foo')).not.toBeInTheDocument()`
125
+ ) ,
126
+ invalidCase (
127
+ `expect(screen.getAllByRole('foo')).toHaveLength(0,2,3,)` ,
128
+ `expect(screen.getByRole('foo')).not.toBeInTheDocument()`
129
+ ) ,
130
+ invalidCase (
131
+ `expect(screen.getByRole('foo')).toHaveLength(1,2,3)` ,
132
+ `expect(screen.getByRole('foo')).toBeInTheDocument()`
133
+ ) ,
134
+ invalidCase (
135
+ `expect(screen.getAllByRole('foo')).toHaveLength(1,2,3,)` ,
136
+ `expect(screen.getByRole('foo')).toBeInTheDocument()`
137
+ ) ,
138
+ invalidCase (
139
+ `expect(screen.getAllByRole('foo')).toHaveLength(0//comment
140
+ )` ,
141
+ `expect(screen.getByRole('foo')).not.toBeInTheDocument(//comment
142
+ )`
143
+ ) ,
144
+ invalidCase (
145
+ `expect(screen.getAllByRole('foo')).toHaveLength(1,//comment
146
+ )` ,
147
+ `expect(screen.getByRole('foo')).toBeInTheDocument(//comment
148
+ )`
149
+ ) ,
150
+ invalidCase (
151
+ `expect(screen.getAllByRole('foo')).toHaveLength(0,2,3//comment
152
+ )` ,
153
+ `expect(screen.getByRole('foo')).not.toBeInTheDocument(//comment
154
+ )`
155
+ ) ,
156
+ invalidCase (
157
+ `expect(screen.getAllByRole('foo')).toHaveLength(1,2,3,//comment
158
+ )` ,
159
+ `expect(screen.getByRole('foo')).toBeInTheDocument(//comment
160
+ )`
161
+ ) ,
162
+ invalidCase (
163
+ `expect(screen.getAllByRole('foo')).toHaveLength(0,2,//comment
164
+ 3,4)` ,
165
+ `expect(screen.getByRole('foo')).not.toBeInTheDocument(//comment
166
+ )`
167
+ ) ,
168
+ invalidCase (
169
+ `expect(screen.getAllByRole('foo')).toHaveLength(1,2,//comment
170
+ 3,4,)` ,
171
+ `expect(screen.getByRole('foo')).toBeInTheDocument(//comment
172
+ )`
173
+ ) ,
174
+ invalidCase (
175
+ `expect(screen.getAllByRole('foo')).toHaveLength(0,2/*comment*/,3)` ,
176
+ `expect(screen.getByRole('foo')).not.toBeInTheDocument(/*comment*/)`
177
+ ) ,
178
+ invalidCase (
179
+ `expect(screen.getAllByRole('foo')).toHaveLength(1,2,/*comment*/3,)` ,
180
+ `expect(screen.getByRole('foo')).toBeInTheDocument(/*comment*/)`
181
+ ) ,
102
182
invalidCase (
103
183
`expect(screen.getByText('foo')).toHaveLength(1)` ,
104
184
`expect(screen.getByText('foo')).toBeInTheDocument()`
0 commit comments