@@ -49,7 +49,7 @@ const valid = [
49
49
] ;
50
50
const invalid = [
51
51
// Invalid cases that applies to all variants
52
- ...[ "getByText" , "getByRole " ] . map ( ( q ) => [
52
+ ...[ "getByText" , "getAllByRole " ] . map ( ( q ) => [
53
53
invalidCase (
54
54
`expect(screen.${ q } ('foo')).toHaveLength(1)` ,
55
55
`expect(screen.${ q } ('foo')).toBeInTheDocument()`
@@ -92,7 +92,7 @@ const invalid = [
92
92
) ,
93
93
] ) ,
94
94
// Invalid cases that applies to queryBy* and queryAllBy*
95
- ...[ "queryByText" ] . map ( ( q ) => [
95
+ ...[ "queryByText" , "queryAllByText" ] . map ( ( q ) => [
96
96
invalidCase (
97
97
`expect(${ q } ('foo')).toHaveLength(0)` ,
98
98
`expect(${ q } ('foo')).not.toBeInTheDocument()`
@@ -148,6 +148,14 @@ const invalid = [
148
148
expect(await findByRole("button")).toBeInTheDocument();
149
149
})`
150
150
) ,
151
+ invalidCase (
152
+ `it("foo", async () => {
153
+ expect(await findByRole("button")).not.toBeNull();
154
+ })` ,
155
+ `it("foo", async () => {
156
+ expect(await findByRole("button")).toBeInTheDocument();
157
+ })`
158
+ ) ,
151
159
invalidCase (
152
160
`it("foo", async () => {
153
161
expect(await screen.findByText(/Compressing video/)).toBeDefined();
@@ -156,6 +164,14 @@ const invalid = [
156
164
expect(await screen.findByText(/Compressing video/)).toBeInTheDocument();
157
165
})`
158
166
) ,
167
+ invalidCase (
168
+ `it("foo", async () => {
169
+ expect(await screen.findByText(/Compressing video/)).not.toBeDefined();
170
+ })` ,
171
+ `it("foo", async () => {
172
+ expect(await screen.findByText(/Compressing video/)).not.toBeInTheDocument();
173
+ })`
174
+ ) ,
159
175
invalidCase (
160
176
`it("foo", async () => {
161
177
const compressingFeedback = await screen.findByText(/Compressing video/);
@@ -166,6 +182,16 @@ const invalid = [
166
182
expect(compressingFeedback).toBeInTheDocument();
167
183
});`
168
184
) ,
185
+ invalidCase (
186
+ `it("foo", async () => {
187
+ const compressingFeedback = await screen.findByText(/Compressing video/);
188
+ expect(compressingFeedback).not.toBeNull();
189
+ });` ,
190
+ `it("foo", async () => {
191
+ const compressingFeedback = await screen.findByText(/Compressing video/);
192
+ expect(compressingFeedback).toBeInTheDocument();
193
+ });`
194
+ ) ,
169
195
invalidCase (
170
196
`it("foo", async () => {
171
197
let compressingFeedback;
@@ -178,6 +204,18 @@ const invalid = [
178
204
expect(compressingFeedback).toBeInTheDocument();
179
205
});`
180
206
) ,
207
+ invalidCase (
208
+ `it("foo", async () => {
209
+ let compressingFeedback;
210
+ compressingFeedback = await screen.findByText(/Compressing video/);
211
+ expect(compressingFeedback).not.toBeDefined();
212
+ });` ,
213
+ `it("foo", async () => {
214
+ let compressingFeedback;
215
+ compressingFeedback = await screen.findByText(/Compressing video/);
216
+ expect(compressingFeedback).not.toBeInTheDocument();
217
+ });`
218
+ ) ,
181
219
] ;
182
220
183
221
const ruleTester = new RuleTester ( { parserOptions : { ecmaVersion : 2017 } } ) ;
0 commit comments