eslint-plugin-jest 27.2.2 → 27.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +1 -0
  2. package/docs/rules/no-confusing-set-timeout.md +62 -0
  3. package/lib/rules/expect-expect.js +3 -1
  4. package/lib/rules/no-confusing-set-timeout.js +65 -0
  5. package/lib/rules/no-deprecated-functions.js +2 -2
  6. package/lib/rules/no-test-return-statement.js +9 -3
  7. package/lib/rules/no-untyped-mock-factory.js +3 -1
  8. package/lib/rules/prefer-spy-on.js +6 -2
  9. package/lib/rules/unbound-method.js +1 -1
  10. package/package.json +13 -16
  11. package/lib/processors/__tests__/snapshot-processor.test.js +0 -36
  12. package/lib/rules/__tests__/consistent-test-it.test.js +0 -921
  13. package/lib/rules/__tests__/expect-expect.test.js +0 -347
  14. package/lib/rules/__tests__/fixtures/class.ts +0 -13
  15. package/lib/rules/__tests__/fixtures/file.ts +0 -0
  16. package/lib/rules/__tests__/fixtures/foo.ts +0 -1
  17. package/lib/rules/__tests__/fixtures/indent/indent-invalid-fixture-1.js +0 -530
  18. package/lib/rules/__tests__/fixtures/indent/indent-valid-fixture-1.js +0 -530
  19. package/lib/rules/__tests__/fixtures/react.tsx +0 -0
  20. package/lib/rules/__tests__/fixtures/tsconfig-withmeta.json +0 -6
  21. package/lib/rules/__tests__/fixtures/tsconfig.json +0 -16
  22. package/lib/rules/__tests__/fixtures/unstrict/file.ts +0 -0
  23. package/lib/rules/__tests__/fixtures/unstrict/react.tsx +0 -0
  24. package/lib/rules/__tests__/fixtures/unstrict/tsconfig.json +0 -15
  25. package/lib/rules/__tests__/max-expects.test.js +0 -330
  26. package/lib/rules/__tests__/max-nested-describe.test.js +0 -247
  27. package/lib/rules/__tests__/no-alias-methods.test.js +0 -190
  28. package/lib/rules/__tests__/no-commented-out-tests.test.js +0 -213
  29. package/lib/rules/__tests__/no-conditional-expect.test.js +0 -696
  30. package/lib/rules/__tests__/no-conditional-in-test.test.js +0 -777
  31. package/lib/rules/__tests__/no-deprecated-functions.test.js +0 -119
  32. package/lib/rules/__tests__/no-disabled-tests.test.js +0 -241
  33. package/lib/rules/__tests__/no-done-callback.test.js +0 -424
  34. package/lib/rules/__tests__/no-duplicate-hooks.test.js +0 -469
  35. package/lib/rules/__tests__/no-export.test.js +0 -107
  36. package/lib/rules/__tests__/no-focused-tests.test.js +0 -373
  37. package/lib/rules/__tests__/no-hooks.test.js +0 -90
  38. package/lib/rules/__tests__/no-identical-title.test.js +0 -270
  39. package/lib/rules/__tests__/no-if.test.js +0 -787
  40. package/lib/rules/__tests__/no-interpolation-in-snapshots.test.js +0 -58
  41. package/lib/rules/__tests__/no-jasmine-globals.test.js +0 -206
  42. package/lib/rules/__tests__/no-large-snapshots.test.js +0 -237
  43. package/lib/rules/__tests__/no-mocks-import.test.js +0 -73
  44. package/lib/rules/__tests__/no-restricted-jest-methods.test.js +0 -103
  45. package/lib/rules/__tests__/no-restricted-matchers.test.js +0 -244
  46. package/lib/rules/__tests__/no-standalone-expect.test.js +0 -230
  47. package/lib/rules/__tests__/no-test-prefixes.test.js +0 -206
  48. package/lib/rules/__tests__/no-test-return-statement.test.js +0 -122
  49. package/lib/rules/__tests__/no-untyped-mock-factory.test.js +0 -149
  50. package/lib/rules/__tests__/prefer-called-with.test.js +0 -40
  51. package/lib/rules/__tests__/prefer-comparison-matcher.test.js +0 -200
  52. package/lib/rules/__tests__/prefer-each.test.js +0 -295
  53. package/lib/rules/__tests__/prefer-equality-matcher.test.js +0 -184
  54. package/lib/rules/__tests__/prefer-expect-assertions.test.js +0 -1437
  55. package/lib/rules/__tests__/prefer-expect-resolves.test.js +0 -96
  56. package/lib/rules/__tests__/prefer-hooks-in-order.test.js +0 -678
  57. package/lib/rules/__tests__/prefer-hooks-on-top.test.js +0 -218
  58. package/lib/rules/__tests__/prefer-lowercase-title.test.js +0 -619
  59. package/lib/rules/__tests__/prefer-mock-promise-shorthand.test.js +0 -360
  60. package/lib/rules/__tests__/prefer-snapshot-hint.test.js +0 -784
  61. package/lib/rules/__tests__/prefer-spy-on.test.js +0 -100
  62. package/lib/rules/__tests__/prefer-strict-equal.test.js +0 -46
  63. package/lib/rules/__tests__/prefer-to-be.test.js +0 -438
  64. package/lib/rules/__tests__/prefer-to-contain.test.js +0 -301
  65. package/lib/rules/__tests__/prefer-to-have-length.test.js +0 -99
  66. package/lib/rules/__tests__/prefer-todo.test.js +0 -78
  67. package/lib/rules/__tests__/require-hook.test.js +0 -403
  68. package/lib/rules/__tests__/require-to-throw-message.test.js +0 -108
  69. package/lib/rules/__tests__/require-top-level-describe.test.js +0 -236
  70. package/lib/rules/__tests__/test-utils.js +0 -11
  71. package/lib/rules/__tests__/unbound-method.test.js +0 -518
  72. package/lib/rules/__tests__/valid-describe-callback.test.js +0 -305
  73. package/lib/rules/__tests__/valid-expect-in-promise.test.js +0 -1583
  74. package/lib/rules/__tests__/valid-expect.test.js +0 -894
  75. package/lib/rules/__tests__/valid-title.test.js +0 -1147
  76. package/lib/rules/utils/__tests__/detectJestVersion.test.js +0 -221
  77. package/lib/rules/utils/__tests__/parseJestFnCall.test.js +0 -809
@@ -1,777 +0,0 @@
1
- "use strict";
2
-
3
- var _utils = require("@typescript-eslint/utils");
4
- var _dedent = _interopRequireDefault(require("dedent"));
5
- var _noConditionalInTest = _interopRequireDefault(require("../no-conditional-in-test"));
6
- var _testUtils = require("./test-utils");
7
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
- const ruleTester = new _utils.TSESLint.RuleTester({
9
- parser: _testUtils.espreeParser,
10
- parserOptions: {
11
- ecmaVersion: 2015
12
- }
13
- });
14
- ruleTester.run('conditional expressions', _noConditionalInTest.default, {
15
- valid: ['const x = y ? 1 : 0', (0, _dedent.default)`
16
- const foo = function (bar) {
17
- return foo ? bar : null;
18
- };
19
-
20
- it('foo', () => {
21
- foo();
22
- });
23
- `, (0, _dedent.default)`
24
- const foo = function (bar) {
25
- return foo ? bar : null;
26
- };
27
-
28
- it.each()('foo', function () {
29
- foo();
30
- });
31
- `, (0, _dedent.default)`
32
- fit.concurrent('foo', () => {
33
- switch('bar') {}
34
- })
35
- `],
36
- invalid: [{
37
- code: (0, _dedent.default)`
38
- it('foo', () => {
39
- expect(bar ? foo : baz).toBe(boo);
40
- })
41
- `,
42
- errors: [{
43
- messageId: 'conditionalInTest',
44
- column: 10,
45
- line: 2
46
- }]
47
- }, {
48
- code: (0, _dedent.default)`
49
- it('foo', function () {
50
- const foo = function (bar) {
51
- return foo ? bar : null;
52
- };
53
- });
54
- `,
55
- errors: [{
56
- messageId: 'conditionalInTest',
57
- column: 12,
58
- line: 3
59
- }]
60
- }, {
61
- code: (0, _dedent.default)`
62
- it('foo', () => {
63
- const foo = bar ? foo : baz;
64
- })
65
- `,
66
- errors: [{
67
- messageId: 'conditionalInTest',
68
- column: 15,
69
- line: 2
70
- }]
71
- }, {
72
- code: (0, _dedent.default)`
73
- it('foo', () => {
74
- const foo = bar ? foo : baz;
75
- })
76
- const foo = bar ? foo : baz;
77
- `,
78
- errors: [{
79
- messageId: 'conditionalInTest',
80
- column: 15,
81
- line: 2
82
- }]
83
- }, {
84
- code: (0, _dedent.default)`
85
- it('foo', () => {
86
- const foo = bar ? foo : baz;
87
- const anotherFoo = anotherBar ? anotherFoo : anotherBaz;
88
- })
89
- `,
90
- errors: [{
91
- messageId: 'conditionalInTest',
92
- column: 15,
93
- line: 2
94
- }, {
95
- messageId: 'conditionalInTest',
96
- column: 22,
97
- line: 3
98
- }]
99
- }]
100
- });
101
- ruleTester.run('switch statements', _noConditionalInTest.default, {
102
- valid: [`it('foo', () => {})`, (0, _dedent.default)`
103
- switch (true) {
104
- case true: {}
105
- }
106
- `, (0, _dedent.default)`
107
- it('foo', () => {});
108
- function myTest() {
109
- switch ('bar') {
110
- }
111
- }
112
- `, (0, _dedent.default)`
113
- foo('bar', () => {
114
- switch(baz) {}
115
- })
116
- `, (0, _dedent.default)`
117
- describe('foo', () => {
118
- switch('bar') {}
119
- })
120
- `, (0, _dedent.default)`
121
- describe.skip('foo', () => {
122
- switch('bar') {}
123
- })
124
- `, (0, _dedent.default)`
125
- describe.skip.each()('foo', () => {
126
- switch('bar') {}
127
- })
128
- `, (0, _dedent.default)`
129
- xdescribe('foo', () => {
130
- switch('bar') {}
131
- })
132
- `, (0, _dedent.default)`
133
- fdescribe('foo', () => {
134
- switch('bar') {}
135
- })
136
- `, (0, _dedent.default)`
137
- describe('foo', () => {
138
- switch('bar') {}
139
- })
140
- switch('bar') {}
141
- `, (0, _dedent.default)`
142
- describe('foo', () => {
143
- afterEach(() => {
144
- switch('bar') {}
145
- });
146
- });
147
- `, (0, _dedent.default)`
148
- const values = something.map(thing => {
149
- switch (thing.isFoo) {
150
- case true:
151
- return thing.foo;
152
- default:
153
- return thing.bar;
154
- }
155
- });
156
-
157
- it('valid', () => {
158
- expect(values).toStrictEqual(['foo']);
159
- });
160
- `, (0, _dedent.default)`
161
- describe('valid', () => {
162
- const values = something.map(thing => {
163
- switch (thing.isFoo) {
164
- case true:
165
- return thing.foo;
166
- default:
167
- return thing.bar;
168
- }
169
- });
170
- it('still valid', () => {
171
- expect(values).toStrictEqual(['foo']);
172
- });
173
- });
174
- `],
175
- invalid: [{
176
- code: (0, _dedent.default)`
177
- it('is invalid', () => {
178
- const values = something.map(thing => {
179
- switch (thing.isFoo) {
180
- case true:
181
- return thing.foo;
182
- default:
183
- return thing.bar;
184
- }
185
- });
186
-
187
- expect(values).toStrictEqual(['foo']);
188
- });
189
- `,
190
- errors: [{
191
- messageId: 'conditionalInTest',
192
- column: 5,
193
- line: 3
194
- }]
195
- }, {
196
- code: (0, _dedent.default)`
197
- it('foo', () => {
198
- switch (true) {
199
- case true: {}
200
- }
201
- })
202
- `,
203
- errors: [{
204
- messageId: 'conditionalInTest',
205
- column: 3,
206
- line: 2
207
- }]
208
- }, {
209
- code: (0, _dedent.default)`
210
- it('foo', () => {
211
- switch('bar') {}
212
- })
213
- `,
214
- errors: [{
215
- messageId: 'conditionalInTest',
216
- column: 3,
217
- line: 2
218
- }]
219
- }, {
220
- code: (0, _dedent.default)`
221
- it.skip('foo', () => {
222
- switch('bar') {}
223
- })
224
- `,
225
- errors: [{
226
- messageId: 'conditionalInTest',
227
- column: 3,
228
- line: 2
229
- }]
230
- }, {
231
- code: (0, _dedent.default)`
232
- it.only('foo', () => {
233
- switch('bar') {}
234
- })
235
- `,
236
- errors: [{
237
- messageId: 'conditionalInTest',
238
- column: 3,
239
- line: 2
240
- }]
241
- }, {
242
- code: (0, _dedent.default)`
243
- xit('foo', () => {
244
- switch('bar') {}
245
- })
246
- `,
247
- errors: [{
248
- messageId: 'conditionalInTest',
249
- column: 3,
250
- line: 2
251
- }]
252
- }, {
253
- code: (0, _dedent.default)`
254
- fit('foo', () => {
255
- switch('bar') {}
256
- })
257
- `,
258
- errors: [{
259
- messageId: 'conditionalInTest',
260
- column: 3,
261
- line: 2
262
- }]
263
- }, {
264
- code: (0, _dedent.default)`
265
- test('foo', () => {
266
- switch('bar') {}
267
- })
268
- `,
269
- errors: [{
270
- messageId: 'conditionalInTest',
271
- column: 3,
272
- line: 2
273
- }]
274
- }, {
275
- code: (0, _dedent.default)`
276
- test.skip('foo', () => {
277
- switch('bar') {}
278
- })
279
- `,
280
- errors: [{
281
- messageId: 'conditionalInTest',
282
- column: 3,
283
- line: 2
284
- }]
285
- }, {
286
- code: (0, _dedent.default)`
287
- test.only('foo', () => {
288
- switch('bar') {}
289
- })
290
- `,
291
- errors: [{
292
- messageId: 'conditionalInTest',
293
- column: 3,
294
- line: 2
295
- }]
296
- }, {
297
- code: (0, _dedent.default)`
298
- xtest('foo', () => {
299
- switch('bar') {}
300
- })
301
- `,
302
- errors: [{
303
- messageId: 'conditionalInTest',
304
- column: 3,
305
- line: 2
306
- }]
307
- }, {
308
- code: (0, _dedent.default)`
309
- xtest('foo', function () {
310
- switch('bar') {}
311
- })
312
- `,
313
- errors: [{
314
- messageId: 'conditionalInTest',
315
- column: 3,
316
- line: 2
317
- }]
318
- }, {
319
- code: (0, _dedent.default)`
320
- describe('foo', () => {
321
- it('bar', () => {
322
-
323
- switch('bar') {}
324
- })
325
- })
326
- `,
327
- errors: [{
328
- messageId: 'conditionalInTest',
329
- column: 5,
330
- line: 4
331
- }]
332
- }, {
333
- code: (0, _dedent.default)`
334
- describe('foo', () => {
335
- it('bar', () => {
336
- switch('bar') {}
337
- })
338
- it('baz', () => {
339
- switch('qux') {}
340
- switch('quux') {}
341
- })
342
- })
343
- `,
344
- errors: [{
345
- messageId: 'conditionalInTest',
346
- column: 5,
347
- line: 3
348
- }, {
349
- messageId: 'conditionalInTest',
350
- column: 5,
351
- line: 6
352
- }, {
353
- messageId: 'conditionalInTest',
354
- column: 5,
355
- line: 7
356
- }]
357
- }, {
358
- code: (0, _dedent.default)`
359
- it('foo', () => {
360
- callExpression()
361
- switch ('bar') {}
362
- })
363
- `,
364
- errors: [{
365
- messageId: 'conditionalInTest',
366
- column: 3,
367
- line: 3
368
- }]
369
- }, {
370
- code: (0, _dedent.default)`
371
- describe('valid', () => {
372
- describe('still valid', () => {
373
- it('is not valid', () => {
374
- const values = something.map((thing) => {
375
- switch (thing.isFoo) {
376
- case true:
377
- return thing.foo;
378
- default:
379
- return thing.bar;
380
- }
381
- });
382
-
383
- switch('invalid') {
384
- case true:
385
- expect(values).toStrictEqual(['foo']);
386
- }
387
- });
388
- });
389
- });
390
- `,
391
- errors: [{
392
- messageId: 'conditionalInTest',
393
- column: 9,
394
- line: 5
395
- }, {
396
- messageId: 'conditionalInTest',
397
- column: 7,
398
- line: 13
399
- }]
400
- }]
401
- });
402
- ruleTester.run('if statements', _noConditionalInTest.default, {
403
- valid: ['if (foo) {}', "it('foo', () => {})", 'it("foo", function () {})', "it('foo', () => {}); function myTest() { if ('bar') {} }", (0, _dedent.default)`
404
- foo('bar', () => {
405
- if (baz) {}
406
- })
407
- `, (0, _dedent.default)`
408
- describe('foo', () => {
409
- if ('bar') {}
410
- })
411
- `, (0, _dedent.default)`
412
- describe.skip('foo', () => {
413
- if ('bar') {}
414
- })
415
- `, (0, _dedent.default)`
416
- xdescribe('foo', () => {
417
- if ('bar') {}
418
- })
419
- `, (0, _dedent.default)`
420
- fdescribe('foo', () => {
421
- if ('bar') {}
422
- })
423
- `, (0, _dedent.default)`
424
- describe('foo', () => {
425
- if ('bar') {}
426
- })
427
- if ('baz') {}
428
- `, (0, _dedent.default)`
429
- describe('foo', () => {
430
- afterEach(() => {
431
- if ('bar') {}
432
- });
433
- })
434
- `, (0, _dedent.default)`
435
- describe.each\`\`('foo', () => {
436
- afterEach(() => {
437
- if ('bar') {}
438
- });
439
- })
440
- `, (0, _dedent.default)`
441
- describe('foo', () => {
442
- beforeEach(() => {
443
- if ('bar') {}
444
- });
445
- })
446
- `, 'const foo = bar ? foo : baz;', (0, _dedent.default)`
447
- const values = something.map((thing) => {
448
- if (thing.isFoo) {
449
- return thing.foo
450
- } else {
451
- return thing.bar;
452
- }
453
- });
454
-
455
- describe('valid', () => {
456
- it('still valid', () => {
457
- expect(values).toStrictEqual(['foo']);
458
- });
459
- });
460
- `, (0, _dedent.default)`
461
- describe('valid', () => {
462
- const values = something.map((thing) => {
463
- if (thing.isFoo) {
464
- return thing.foo
465
- } else {
466
- return thing.bar;
467
- }
468
- });
469
-
470
- describe('still valid', () => {
471
- it('really still valid', () => {
472
- expect(values).toStrictEqual(['foo']);
473
- });
474
- });
475
- });
476
- `, (0, _dedent.default)`
477
- fit.concurrent('foo', () => {
478
- if ('bar') {}
479
- })
480
- `],
481
- invalid: [{
482
- code: (0, _dedent.default)`
483
- it('foo', () => {
484
- const foo = function(bar) {
485
- if (bar) {
486
- return 1;
487
- } else {
488
- return 2;
489
- }
490
- };
491
- });
492
- `,
493
- errors: [{
494
- messageId: 'conditionalInTest',
495
- column: 5,
496
- line: 3
497
- }]
498
- }, {
499
- code: (0, _dedent.default)`
500
- it('foo', () => {
501
- function foo(bar) {
502
- if (bar) {
503
- return 1;
504
- } else {
505
- return 2;
506
- }
507
- };
508
- });
509
- `,
510
- errors: [{
511
- messageId: 'conditionalInTest',
512
- column: 5,
513
- line: 3
514
- }]
515
- }, {
516
- code: (0, _dedent.default)`
517
- it('foo', () => {
518
- if ('bar') {}
519
- })
520
- `,
521
- errors: [{
522
- messageId: 'conditionalInTest',
523
- column: 3,
524
- line: 2
525
- }]
526
- }, {
527
- code: (0, _dedent.default)`
528
- it.skip('foo', () => {
529
- if ('bar') {}
530
- })
531
- `,
532
- errors: [{
533
- messageId: 'conditionalInTest',
534
- column: 3,
535
- line: 2
536
- }]
537
- }, {
538
- code: (0, _dedent.default)`
539
- it.skip('foo', function () {
540
- if ('bar') {}
541
- })
542
- `,
543
- errors: [{
544
- messageId: 'conditionalInTest',
545
- column: 3,
546
- line: 2
547
- }]
548
- }, {
549
- code: (0, _dedent.default)`
550
- it.only('foo', () => {
551
- if ('bar') {}
552
- })
553
- `,
554
- errors: [{
555
- messageId: 'conditionalInTest',
556
- column: 3,
557
- line: 2
558
- }]
559
- }, {
560
- code: (0, _dedent.default)`
561
- xit('foo', () => {
562
- if ('bar') {}
563
- })
564
- `,
565
- errors: [{
566
- messageId: 'conditionalInTest',
567
- column: 3,
568
- line: 2
569
- }]
570
- }, {
571
- code: (0, _dedent.default)`
572
- fit('foo', () => {
573
- if ('bar') {}
574
- })
575
- `,
576
- errors: [{
577
- messageId: 'conditionalInTest',
578
- column: 3,
579
- line: 2
580
- }]
581
- }, {
582
- code: (0, _dedent.default)`
583
- test('foo', () => {
584
- if ('bar') {}
585
- })
586
- `,
587
- errors: [{
588
- messageId: 'conditionalInTest',
589
- column: 3,
590
- line: 2
591
- }]
592
- }, {
593
- code: (0, _dedent.default)`
594
- test.skip('foo', () => {
595
- if ('bar') {}
596
- })
597
- `,
598
- errors: [{
599
- messageId: 'conditionalInTest',
600
- column: 3,
601
- line: 2
602
- }]
603
- }, {
604
- code: (0, _dedent.default)`
605
- test.only('foo', () => {
606
- if ('bar') {}
607
- })
608
- `,
609
- errors: [{
610
- messageId: 'conditionalInTest',
611
- column: 3,
612
- line: 2
613
- }]
614
- }, {
615
- code: (0, _dedent.default)`
616
- xtest('foo', () => {
617
- if ('bar') {}
618
- })
619
- `,
620
- errors: [{
621
- messageId: 'conditionalInTest',
622
- column: 3,
623
- line: 2
624
- }]
625
- }, {
626
- code: (0, _dedent.default)`
627
- describe('foo', () => {
628
- it('bar', () => {
629
- if ('bar') {}
630
- })
631
- })
632
- `,
633
- errors: [{
634
- messageId: 'conditionalInTest',
635
- column: 5,
636
- line: 3
637
- }]
638
- }, {
639
- code: (0, _dedent.default)`
640
- describe('foo', () => {
641
- it('bar', () => {
642
- if ('bar') {}
643
- })
644
- it('baz', () => {
645
- if ('qux') {}
646
- if ('quux') {}
647
- })
648
- })
649
- `,
650
- errors: [{
651
- messageId: 'conditionalInTest',
652
- column: 5,
653
- line: 3
654
- }, {
655
- messageId: 'conditionalInTest',
656
- column: 5,
657
- line: 6
658
- }, {
659
- messageId: 'conditionalInTest',
660
- column: 5,
661
- line: 7
662
- }]
663
- }, {
664
- code: (0, _dedent.default)`
665
- it('foo', () => {
666
- callExpression()
667
- if ('bar') {}
668
- })
669
- `,
670
- errors: [{
671
- messageId: 'conditionalInTest',
672
- column: 3,
673
- line: 3
674
- }]
675
- }, {
676
- code: (0, _dedent.default)`
677
- it.each\`\`('foo', () => {
678
- callExpression()
679
- if ('bar') {}
680
- })
681
- `,
682
- errors: [{
683
- messageId: 'conditionalInTest',
684
- column: 3,
685
- line: 3
686
- }]
687
- }, {
688
- code: (0, _dedent.default)`
689
- it.each()('foo', () => {
690
- callExpression()
691
- if ('bar') {}
692
- })
693
- `,
694
- errors: [{
695
- messageId: 'conditionalInTest',
696
- column: 3,
697
- line: 3
698
- }]
699
- }, {
700
- code: (0, _dedent.default)`
701
- it.only.each\`\`('foo', () => {
702
- callExpression()
703
- if ('bar') {}
704
- })
705
- `,
706
- errors: [{
707
- messageId: 'conditionalInTest',
708
- column: 3,
709
- line: 3
710
- }]
711
- }, {
712
- code: (0, _dedent.default)`
713
- it.only.each()('foo', () => {
714
- callExpression()
715
- if ('bar') {}
716
- })
717
- `,
718
- errors: [{
719
- messageId: 'conditionalInTest',
720
- column: 3,
721
- line: 3
722
- }]
723
- }, {
724
- code: (0, _dedent.default)`
725
- describe('valid', () => {
726
- describe('still valid', () => {
727
- it('is invalid', () => {
728
- const values = something.map((thing) => {
729
- if (thing.isFoo) {
730
- return thing.foo
731
- } else {
732
- return thing.bar;
733
- }
734
- });
735
-
736
- if ('invalid') {
737
- expect(values).toStrictEqual(['foo']);
738
- }
739
- });
740
- });
741
- });
742
- `,
743
- errors: [{
744
- messageId: 'conditionalInTest',
745
- column: 9,
746
- line: 5
747
- }, {
748
- messageId: 'conditionalInTest',
749
- column: 7,
750
- line: 12
751
- }]
752
- }, {
753
- code: (0, _dedent.default)`
754
- test("shows error", () => {
755
- if (1 === 2) {
756
- expect(true).toBe(false);
757
- }
758
- });
759
-
760
- test("does not show error", () => {
761
- setTimeout(() => console.log("noop"));
762
- if (1 === 2) {
763
- expect(true).toBe(false);
764
- }
765
- });
766
- `,
767
- errors: [{
768
- messageId: 'conditionalInTest',
769
- column: 3,
770
- line: 2
771
- }, {
772
- messageId: 'conditionalInTest',
773
- column: 3,
774
- line: 9
775
- }]
776
- }]
777
- });