@@ -137,6 +137,12 @@ ruleTester.run(RULE_NAME, rule, {
137
137
errors : [
138
138
{ line : 4 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
139
139
] ,
140
+ output : `
141
+ await waitFor(() => {
142
+ expect(a).toEqual('a')
143
+ })
144
+ expect(a).toEqual('a')
145
+ ` ,
140
146
} ,
141
147
{
142
148
code : `
@@ -148,6 +154,12 @@ ruleTester.run(RULE_NAME, rule, {
148
154
errors : [
149
155
{ line : 4 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
150
156
] ,
157
+ output : `
158
+ await waitFor(() => {
159
+ expect(screen.getByTestId('a')).toHaveTextContent('a')
160
+ })
161
+ expect(screen.getByTestId('a')).toHaveTextContent('a')
162
+ ` ,
151
163
} ,
152
164
...SUPPORTED_TESTING_FRAMEWORKS . map < RuleInvalidTestCase > (
153
165
( testingFramework ) => ( {
@@ -162,6 +174,13 @@ ruleTester.run(RULE_NAME, rule, {
162
174
errors : [
163
175
{ line : 5 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
164
176
] ,
177
+ output : `// Aggressive Reporting disabled
178
+ import { waitFor } from '${ testingFramework } '
179
+ await waitFor(() => {
180
+ expect(a).toEqual('a')
181
+ })
182
+ expect(a).toEqual('a')
183
+ ` ,
165
184
} )
166
185
) ,
167
186
{
@@ -176,6 +195,13 @@ ruleTester.run(RULE_NAME, rule, {
176
195
errors : [
177
196
{ line : 5 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
178
197
] ,
198
+ output : `// Aggressive Reporting disabled
199
+ import { waitFor as renamedWaitFor } from 'test-utils'
200
+ await renamedWaitFor(() => {
201
+ expect(a).toEqual('a')
202
+ })
203
+ expect(a).toEqual('a')
204
+ ` ,
179
205
} ,
180
206
{
181
207
code : `
@@ -188,6 +214,13 @@ ruleTester.run(RULE_NAME, rule, {
188
214
errors : [
189
215
{ line : 5 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
190
216
] ,
217
+ output : `
218
+ await waitFor(() => {
219
+ expect(a).toEqual('a')
220
+ console.log('testing-library')
221
+ })
222
+ expect(a).toEqual('a')
223
+ ` ,
191
224
} ,
192
225
{
193
226
code : `
@@ -202,6 +235,15 @@ ruleTester.run(RULE_NAME, rule, {
202
235
errors : [
203
236
{ line : 6 , column : 13 , messageId : 'noWaitForMultipleAssertion' } ,
204
237
] ,
238
+ output : `
239
+ test('should whatever', async () => {
240
+ await waitFor(() => {
241
+ expect(a).toEqual('a')
242
+ console.log('testing-library')
243
+ })
244
+ expect(a).toEqual('a')
245
+ })
246
+ ` ,
205
247
} ,
206
248
{
207
249
code : `
@@ -214,6 +256,13 @@ ruleTester.run(RULE_NAME, rule, {
214
256
errors : [
215
257
{ line : 5 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
216
258
] ,
259
+ output : `
260
+ await waitFor(async () => {
261
+ expect(a).toEqual('a')
262
+ await somethingAsync()
263
+ })
264
+ expect(a).toEqual('a')
265
+ ` ,
217
266
} ,
218
267
{
219
268
code : `
@@ -229,6 +278,32 @@ ruleTester.run(RULE_NAME, rule, {
229
278
{ line : 5 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
230
279
{ line : 6 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
231
280
] ,
281
+ output : [
282
+ `
283
+ await waitFor(function() {
284
+ expect(a).toEqual('a')
285
+ expect(a).toEqual('a')
286
+ expect(a).toEqual('a')
287
+ })
288
+ expect(a).toEqual('a')
289
+ ` ,
290
+ `
291
+ await waitFor(function() {
292
+ expect(a).toEqual('a')
293
+ expect(a).toEqual('a')
294
+ })
295
+ expect(a).toEqual('a')
296
+ expect(a).toEqual('a')
297
+ ` ,
298
+ `
299
+ await waitFor(function() {
300
+ expect(a).toEqual('a')
301
+ })
302
+ expect(a).toEqual('a')
303
+ expect(a).toEqual('a')
304
+ expect(a).toEqual('a')
305
+ ` ,
306
+ ] ,
232
307
} ,
233
308
{
234
309
code : `
@@ -243,6 +318,24 @@ ruleTester.run(RULE_NAME, rule, {
243
318
{ line : 4 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
244
319
{ line : 6 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
245
320
] ,
321
+ output : [
322
+ `
323
+ await waitFor(function() {
324
+ expect(a).toEqual('a')
325
+ expect(b).toEqual('b')
326
+ expect(b).toEqual('b')
327
+ })
328
+ expect(a).toEqual('a')
329
+ ` ,
330
+ `
331
+ await waitFor(function() {
332
+ expect(a).toEqual('a')
333
+ expect(b).toEqual('b')
334
+ })
335
+ expect(b).toEqual('b')
336
+ expect(a).toEqual('a')
337
+ ` ,
338
+ ] ,
246
339
} ,
247
340
{
248
341
code : `
@@ -255,6 +348,13 @@ ruleTester.run(RULE_NAME, rule, {
255
348
errors : [
256
349
{ line : 5 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
257
350
] ,
351
+ output : `
352
+ await waitFor(function() {
353
+ expect(a).toEqual('a')
354
+ console.log('testing-library')
355
+ })
356
+ expect(a).toEqual('a')
357
+ ` ,
258
358
} ,
259
359
{
260
360
code : `
@@ -267,18 +367,51 @@ ruleTester.run(RULE_NAME, rule, {
267
367
errors : [
268
368
{ line : 5 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
269
369
] ,
370
+ output : `
371
+ await waitFor(async function() {
372
+ expect(a).toEqual('a')
373
+ const el = await somethingAsync()
374
+ })
375
+ expect(a).toEqual('a')
376
+ ` ,
270
377
} ,
271
378
{
272
379
code : `
273
380
await waitFor(() => {
274
381
expect(window.fetch).toHaveBeenCalledTimes(1);
275
382
expect(localStorage.setItem).toHaveBeenCalledWith('bar', 'baz');
276
383
expect(window.fetch).toHaveBeenCalledWith('/foo');
277
- });
384
+ })
385
+ ` ,
386
+ errors : [
387
+ { line : 5 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
388
+ ] ,
389
+ output : `
390
+ await waitFor(() => {
391
+ expect(window.fetch).toHaveBeenCalledTimes(1);
392
+ expect(localStorage.setItem).toHaveBeenCalledWith('bar', 'baz');
393
+ })
394
+ expect(window.fetch).toHaveBeenCalledWith('/foo');
395
+ ` ,
396
+ } ,
397
+ {
398
+ code : `
399
+ await waitFor(() => {
400
+ expect(window.fetch).toHaveBeenCalledTimes(1);
401
+ expect(localStorage.setItem).toHaveBeenCalledWith('bar', 'baz');
402
+ expect(window.fetch).toHaveBeenCalledWith('/foo'); // comment
403
+ })
278
404
` ,
279
405
errors : [
280
406
{ line : 5 , column : 11 , messageId : 'noWaitForMultipleAssertion' } ,
281
407
] ,
408
+ output : `
409
+ await waitFor(() => {
410
+ expect(window.fetch).toHaveBeenCalledTimes(1);
411
+ expect(localStorage.setItem).toHaveBeenCalledWith('bar', 'baz');
412
+ })
413
+ expect(window.fetch).toHaveBeenCalledWith('/foo'); // comment
414
+ ` ,
282
415
} ,
283
416
] ,
284
417
} ) ;
0 commit comments