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,921 +0,0 @@
1
- "use strict";
2
-
3
- var _utils = require("@typescript-eslint/utils");
4
- var _dedent = _interopRequireDefault(require("dedent"));
5
- var _consistentTestIt = _interopRequireDefault(require("../consistent-test-it"));
6
- var _utils2 = require("../utils");
7
- var _testUtils = require("./test-utils");
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- const ruleTester = new _utils.TSESLint.RuleTester({
10
- parser: _testUtils.espreeParser,
11
- parserOptions: {
12
- ecmaVersion: 2015
13
- }
14
- });
15
- ruleTester.run('consistent-test-it with fn=test', _consistentTestIt.default, {
16
- valid: [{
17
- code: 'test("foo")',
18
- options: [{
19
- fn: _utils2.TestCaseName.test
20
- }]
21
- }, {
22
- code: 'test.only("foo")',
23
- options: [{
24
- fn: _utils2.TestCaseName.test
25
- }]
26
- }, {
27
- code: 'test.skip("foo")',
28
- options: [{
29
- fn: _utils2.TestCaseName.test
30
- }]
31
- }, {
32
- code: 'test.concurrent("foo")',
33
- options: [{
34
- fn: _utils2.TestCaseName.test
35
- }]
36
- }, {
37
- code: 'xtest("foo")',
38
- options: [{
39
- fn: _utils2.TestCaseName.test
40
- }]
41
- }, {
42
- code: 'test.each([])("foo")',
43
- options: [{
44
- fn: _utils2.TestCaseName.test
45
- }]
46
- }, {
47
- code: 'test.each``("foo")',
48
- options: [{
49
- fn: _utils2.TestCaseName.test
50
- }]
51
- }, {
52
- code: 'describe("suite", () => { test("foo") })',
53
- options: [{
54
- fn: _utils2.TestCaseName.test
55
- }]
56
- }],
57
- invalid: [{
58
- code: 'it("foo")',
59
- output: 'test("foo")',
60
- options: [{
61
- fn: _utils2.TestCaseName.test
62
- }],
63
- errors: [{
64
- messageId: 'consistentMethod',
65
- data: {
66
- testKeyword: _utils2.TestCaseName.test,
67
- oppositeTestKeyword: _utils2.TestCaseName.it
68
- }
69
- }]
70
- }, {
71
- code: (0, _dedent.default)`
72
- import { it } from '@jest/globals';
73
-
74
- it("foo")
75
- `,
76
- output: (0, _dedent.default)`
77
- import { it } from '@jest/globals';
78
-
79
- test("foo")
80
- `,
81
- options: [{
82
- fn: _utils2.TestCaseName.test
83
- }],
84
- parserOptions: {
85
- sourceType: 'module'
86
- },
87
- errors: [{
88
- messageId: 'consistentMethod',
89
- data: {
90
- testKeyword: _utils2.TestCaseName.test,
91
- oppositeTestKeyword: _utils2.TestCaseName.it
92
- }
93
- }]
94
- }, {
95
- code: (0, _dedent.default)`
96
- import { it as testThisThing } from '@jest/globals';
97
-
98
- testThisThing("foo")
99
- `,
100
- output: (0, _dedent.default)`
101
- import { it as testThisThing } from '@jest/globals';
102
-
103
- test("foo")
104
- `,
105
- options: [{
106
- fn: _utils2.TestCaseName.test
107
- }],
108
- parserOptions: {
109
- sourceType: 'module'
110
- },
111
- errors: [{
112
- messageId: 'consistentMethod',
113
- data: {
114
- testKeyword: _utils2.TestCaseName.test,
115
- oppositeTestKeyword: _utils2.TestCaseName.it
116
- }
117
- }]
118
- }, {
119
- code: 'xit("foo")',
120
- output: 'xtest("foo")',
121
- options: [{
122
- fn: _utils2.TestCaseName.test
123
- }],
124
- errors: [{
125
- messageId: 'consistentMethod',
126
- data: {
127
- testKeyword: _utils2.TestCaseName.test,
128
- oppositeTestKeyword: _utils2.TestCaseName.it
129
- }
130
- }]
131
- }, {
132
- code: 'fit("foo")',
133
- output: 'test.only("foo")',
134
- options: [{
135
- fn: _utils2.TestCaseName.test
136
- }],
137
- errors: [{
138
- messageId: 'consistentMethod',
139
- data: {
140
- testKeyword: _utils2.TestCaseName.test,
141
- oppositeTestKeyword: _utils2.TestCaseName.it
142
- }
143
- }]
144
- }, {
145
- code: 'it.skip("foo")',
146
- output: 'test.skip("foo")',
147
- options: [{
148
- fn: _utils2.TestCaseName.test
149
- }],
150
- errors: [{
151
- messageId: 'consistentMethod',
152
- data: {
153
- testKeyword: _utils2.TestCaseName.test,
154
- oppositeTestKeyword: _utils2.TestCaseName.it
155
- }
156
- }]
157
- }, {
158
- code: 'it.concurrent("foo")',
159
- output: 'test.concurrent("foo")',
160
- options: [{
161
- fn: _utils2.TestCaseName.test
162
- }],
163
- errors: [{
164
- messageId: 'consistentMethod',
165
- data: {
166
- testKeyword: _utils2.TestCaseName.test,
167
- oppositeTestKeyword: _utils2.TestCaseName.it
168
- }
169
- }]
170
- }, {
171
- code: 'it.only("foo")',
172
- output: 'test.only("foo")',
173
- options: [{
174
- fn: _utils2.TestCaseName.test
175
- }],
176
- errors: [{
177
- messageId: 'consistentMethod',
178
- data: {
179
- testKeyword: _utils2.TestCaseName.test,
180
- oppositeTestKeyword: _utils2.TestCaseName.it
181
- }
182
- }]
183
- }, {
184
- code: 'it.each([])("foo")',
185
- output: 'test.each([])("foo")',
186
- options: [{
187
- fn: _utils2.TestCaseName.test
188
- }],
189
- errors: [{
190
- messageId: 'consistentMethod',
191
- data: {
192
- testKeyword: _utils2.TestCaseName.test,
193
- oppositeTestKeyword: _utils2.TestCaseName.it
194
- }
195
- }]
196
- }, {
197
- code: 'it.each``("foo")',
198
- output: 'test.each``("foo")',
199
- options: [{
200
- fn: _utils2.TestCaseName.test
201
- }],
202
- errors: [{
203
- messageId: 'consistentMethod',
204
- data: {
205
- testKeyword: _utils2.TestCaseName.test,
206
- oppositeTestKeyword: _utils2.TestCaseName.it
207
- }
208
- }]
209
- }, {
210
- code: 'describe.each``("foo", () => { it.each``("bar") })',
211
- output: 'describe.each``("foo", () => { test.each``("bar") })',
212
- options: [{
213
- fn: _utils2.TestCaseName.test
214
- }],
215
- errors: [{
216
- messageId: 'consistentMethodWithinDescribe',
217
- data: {
218
- testKeywordWithinDescribe: _utils2.TestCaseName.test,
219
- oppositeTestKeyword: _utils2.TestCaseName.it
220
- }
221
- }]
222
- }, {
223
- code: 'describe.each``("foo", () => { test.each``("bar") })',
224
- output: 'describe.each``("foo", () => { it.each``("bar") })',
225
- options: [{
226
- fn: _utils2.TestCaseName.it
227
- }],
228
- errors: [{
229
- messageId: 'consistentMethodWithinDescribe',
230
- data: {
231
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
232
- oppositeTestKeyword: _utils2.TestCaseName.test
233
- }
234
- }]
235
- }, {
236
- code: (0, _dedent.default)`
237
- describe.each()("%s", () => {
238
- test("is valid, but should not be", () => {});
239
-
240
- it("is not valid, but should be", () => {});
241
- });
242
- `,
243
- output: (0, _dedent.default)`
244
- describe.each()("%s", () => {
245
- it("is valid, but should not be", () => {});
246
-
247
- it("is not valid, but should be", () => {});
248
- });
249
- `,
250
- options: [{
251
- fn: _utils2.TestCaseName.test,
252
- withinDescribe: _utils2.TestCaseName.it
253
- }],
254
- errors: [{
255
- messageId: 'consistentMethodWithinDescribe',
256
- data: {
257
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
258
- oppositeTestKeyword: _utils2.TestCaseName.test
259
- }
260
- }]
261
- }, {
262
- code: (0, _dedent.default)`
263
- describe.only.each()("%s", () => {
264
- test("is valid, but should not be", () => {});
265
-
266
- it("is not valid, but should be", () => {});
267
- });
268
- `,
269
- output: (0, _dedent.default)`
270
- describe.only.each()("%s", () => {
271
- it("is valid, but should not be", () => {});
272
-
273
- it("is not valid, but should be", () => {});
274
- });
275
- `,
276
- options: [{
277
- fn: _utils2.TestCaseName.test,
278
- withinDescribe: _utils2.TestCaseName.it
279
- }],
280
- errors: [{
281
- messageId: 'consistentMethodWithinDescribe',
282
- data: {
283
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
284
- oppositeTestKeyword: _utils2.TestCaseName.test
285
- }
286
- }]
287
- }, {
288
- code: 'describe("suite", () => { it("foo") })',
289
- output: 'describe("suite", () => { test("foo") })',
290
- options: [{
291
- fn: _utils2.TestCaseName.test
292
- }],
293
- errors: [{
294
- messageId: 'consistentMethodWithinDescribe',
295
- data: {
296
- testKeywordWithinDescribe: _utils2.TestCaseName.test,
297
- oppositeTestKeyword: _utils2.TestCaseName.it
298
- }
299
- }]
300
- }]
301
- });
302
- ruleTester.run('consistent-test-it with fn=it', _consistentTestIt.default, {
303
- valid: [{
304
- code: 'it("foo")',
305
- options: [{
306
- fn: _utils2.TestCaseName.it
307
- }]
308
- }, {
309
- code: 'fit("foo")',
310
- options: [{
311
- fn: _utils2.TestCaseName.it
312
- }]
313
- }, {
314
- code: 'xit("foo")',
315
- options: [{
316
- fn: _utils2.TestCaseName.it
317
- }]
318
- }, {
319
- code: 'it.only("foo")',
320
- options: [{
321
- fn: _utils2.TestCaseName.it
322
- }]
323
- }, {
324
- code: 'it.skip("foo")',
325
- options: [{
326
- fn: _utils2.TestCaseName.it
327
- }]
328
- }, {
329
- code: 'it.concurrent("foo")',
330
- options: [{
331
- fn: _utils2.TestCaseName.it
332
- }]
333
- }, {
334
- code: 'it.each([])("foo")',
335
- options: [{
336
- fn: _utils2.TestCaseName.it
337
- }]
338
- }, {
339
- code: 'it.each``("foo")',
340
- options: [{
341
- fn: _utils2.TestCaseName.it
342
- }]
343
- }, {
344
- code: 'describe("suite", () => { it("foo") })',
345
- options: [{
346
- fn: _utils2.TestCaseName.it
347
- }]
348
- }],
349
- invalid: [{
350
- code: 'test("foo")',
351
- output: 'it("foo")',
352
- options: [{
353
- fn: _utils2.TestCaseName.it
354
- }],
355
- errors: [{
356
- messageId: 'consistentMethod',
357
- data: {
358
- testKeyword: _utils2.TestCaseName.it,
359
- oppositeTestKeyword: _utils2.TestCaseName.test
360
- }
361
- }]
362
- }, {
363
- code: 'xtest("foo")',
364
- output: 'xit("foo")',
365
- options: [{
366
- fn: _utils2.TestCaseName.it
367
- }],
368
- errors: [{
369
- messageId: 'consistentMethod',
370
- data: {
371
- testKeyword: _utils2.TestCaseName.it,
372
- oppositeTestKeyword: _utils2.TestCaseName.test
373
- }
374
- }]
375
- }, {
376
- code: 'test.skip("foo")',
377
- output: 'it.skip("foo")',
378
- options: [{
379
- fn: _utils2.TestCaseName.it
380
- }],
381
- errors: [{
382
- messageId: 'consistentMethod',
383
- data: {
384
- testKeyword: _utils2.TestCaseName.it,
385
- oppositeTestKeyword: _utils2.TestCaseName.test
386
- }
387
- }]
388
- }, {
389
- code: 'test.concurrent("foo")',
390
- output: 'it.concurrent("foo")',
391
- options: [{
392
- fn: _utils2.TestCaseName.it
393
- }],
394
- errors: [{
395
- messageId: 'consistentMethod',
396
- data: {
397
- testKeyword: _utils2.TestCaseName.it,
398
- oppositeTestKeyword: _utils2.TestCaseName.test
399
- }
400
- }]
401
- }, {
402
- code: 'test.only("foo")',
403
- output: 'it.only("foo")',
404
- options: [{
405
- fn: _utils2.TestCaseName.it
406
- }],
407
- errors: [{
408
- messageId: 'consistentMethod',
409
- data: {
410
- testKeyword: _utils2.TestCaseName.it,
411
- oppositeTestKeyword: _utils2.TestCaseName.test
412
- }
413
- }]
414
- }, {
415
- code: 'test.each([])("foo")',
416
- output: 'it.each([])("foo")',
417
- options: [{
418
- fn: _utils2.TestCaseName.it
419
- }],
420
- errors: [{
421
- messageId: 'consistentMethod',
422
- data: {
423
- testKeyword: _utils2.TestCaseName.it,
424
- oppositeTestKeyword: _utils2.TestCaseName.test
425
- }
426
- }]
427
- }, {
428
- code: 'describe.each``("foo", () => { test.each``("bar") })',
429
- output: 'describe.each``("foo", () => { it.each``("bar") })',
430
- options: [{
431
- fn: _utils2.TestCaseName.it
432
- }],
433
- errors: [{
434
- messageId: 'consistentMethodWithinDescribe',
435
- data: {
436
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
437
- oppositeTestKeyword: _utils2.TestCaseName.test
438
- }
439
- }]
440
- }, {
441
- code: 'test.each``("foo")',
442
- output: 'it.each``("foo")',
443
- options: [{
444
- fn: _utils2.TestCaseName.it
445
- }],
446
- errors: [{
447
- messageId: 'consistentMethod',
448
- data: {
449
- testKeyword: _utils2.TestCaseName.it,
450
- oppositeTestKeyword: _utils2.TestCaseName.test
451
- }
452
- }]
453
- }, {
454
- code: 'describe("suite", () => { test("foo") })',
455
- output: 'describe("suite", () => { it("foo") })',
456
- options: [{
457
- fn: _utils2.TestCaseName.it
458
- }],
459
- errors: [{
460
- messageId: 'consistentMethodWithinDescribe',
461
- data: {
462
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
463
- oppositeTestKeyword: _utils2.TestCaseName.test
464
- }
465
- }]
466
- }]
467
- });
468
- ruleTester.run('consistent-test-it with fn=test and withinDescribe=it ', _consistentTestIt.default, {
469
- valid: [{
470
- code: 'test("foo")',
471
- options: [{
472
- fn: _utils2.TestCaseName.test,
473
- withinDescribe: _utils2.TestCaseName.it
474
- }]
475
- }, {
476
- code: 'test.only("foo")',
477
- options: [{
478
- fn: _utils2.TestCaseName.test,
479
- withinDescribe: _utils2.TestCaseName.it
480
- }]
481
- }, {
482
- code: 'test.skip("foo")',
483
- options: [{
484
- fn: _utils2.TestCaseName.test,
485
- withinDescribe: _utils2.TestCaseName.it
486
- }]
487
- }, {
488
- code: 'test.concurrent("foo")',
489
- options: [{
490
- fn: _utils2.TestCaseName.test,
491
- withinDescribe: _utils2.TestCaseName.it
492
- }]
493
- }, {
494
- code: 'xtest("foo")',
495
- options: [{
496
- fn: _utils2.TestCaseName.test,
497
- withinDescribe: _utils2.TestCaseName.it
498
- }]
499
- }, {
500
- code: '[1,2,3].forEach(() => { test("foo") })',
501
- options: [{
502
- fn: _utils2.TestCaseName.test,
503
- withinDescribe: _utils2.TestCaseName.it
504
- }]
505
- }],
506
- invalid: [{
507
- code: 'describe("suite", () => { test("foo") })',
508
- output: 'describe("suite", () => { it("foo") })',
509
- options: [{
510
- fn: _utils2.TestCaseName.test,
511
- withinDescribe: _utils2.TestCaseName.it
512
- }],
513
- errors: [{
514
- messageId: 'consistentMethodWithinDescribe',
515
- data: {
516
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
517
- oppositeTestKeyword: _utils2.TestCaseName.test
518
- }
519
- }]
520
- }, {
521
- code: 'describe("suite", () => { test.only("foo") })',
522
- output: 'describe("suite", () => { it.only("foo") })',
523
- options: [{
524
- fn: _utils2.TestCaseName.test,
525
- withinDescribe: _utils2.TestCaseName.it
526
- }],
527
- errors: [{
528
- messageId: 'consistentMethodWithinDescribe',
529
- data: {
530
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
531
- oppositeTestKeyword: _utils2.TestCaseName.test
532
- }
533
- }]
534
- }, {
535
- code: 'describe("suite", () => { xtest("foo") })',
536
- output: 'describe("suite", () => { xit("foo") })',
537
- options: [{
538
- fn: _utils2.TestCaseName.test,
539
- withinDescribe: _utils2.TestCaseName.it
540
- }],
541
- errors: [{
542
- messageId: 'consistentMethodWithinDescribe',
543
- data: {
544
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
545
- oppositeTestKeyword: _utils2.TestCaseName.test
546
- }
547
- }]
548
- }, {
549
- code: (0, _dedent.default)`
550
- import { xtest as dontTestThis } from '@jest/globals';
551
-
552
- describe("suite", () => { dontTestThis("foo") });
553
- `,
554
- output: (0, _dedent.default)`
555
- import { xtest as dontTestThis } from '@jest/globals';
556
-
557
- describe("suite", () => { xit("foo") });
558
- `,
559
- options: [{
560
- fn: _utils2.TestCaseName.test,
561
- withinDescribe: _utils2.TestCaseName.it
562
- }],
563
- parserOptions: {
564
- sourceType: 'module'
565
- },
566
- errors: [{
567
- messageId: 'consistentMethodWithinDescribe',
568
- data: {
569
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
570
- oppositeTestKeyword: _utils2.TestCaseName.test
571
- }
572
- }]
573
- }, {
574
- code: (0, _dedent.default)`
575
- import { describe as context, xtest as dontTestThis } from '@jest/globals';
576
-
577
- context("suite", () => { dontTestThis("foo") });
578
- `,
579
- output: (0, _dedent.default)`
580
- import { describe as context, xtest as dontTestThis } from '@jest/globals';
581
-
582
- context("suite", () => { xit("foo") });
583
- `,
584
- options: [{
585
- fn: _utils2.TestCaseName.test,
586
- withinDescribe: _utils2.TestCaseName.it
587
- }],
588
- parserOptions: {
589
- sourceType: 'module'
590
- },
591
- errors: [{
592
- messageId: 'consistentMethodWithinDescribe',
593
- data: {
594
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
595
- oppositeTestKeyword: _utils2.TestCaseName.test
596
- }
597
- }]
598
- }, {
599
- code: 'describe("suite", () => { test.skip("foo") })',
600
- output: 'describe("suite", () => { it.skip("foo") })',
601
- options: [{
602
- fn: _utils2.TestCaseName.test,
603
- withinDescribe: _utils2.TestCaseName.it
604
- }],
605
- errors: [{
606
- messageId: 'consistentMethodWithinDescribe',
607
- data: {
608
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
609
- oppositeTestKeyword: _utils2.TestCaseName.test
610
- }
611
- }]
612
- }, {
613
- code: 'describe("suite", () => { test.concurrent("foo") })',
614
- output: 'describe("suite", () => { it.concurrent("foo") })',
615
- options: [{
616
- fn: _utils2.TestCaseName.test,
617
- withinDescribe: _utils2.TestCaseName.it
618
- }],
619
- errors: [{
620
- messageId: 'consistentMethodWithinDescribe',
621
- data: {
622
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
623
- oppositeTestKeyword: _utils2.TestCaseName.test
624
- }
625
- }]
626
- }]
627
- });
628
- ruleTester.run('consistent-test-it with fn=it and withinDescribe=test ', _consistentTestIt.default, {
629
- valid: [{
630
- code: 'it("foo")',
631
- options: [{
632
- fn: _utils2.TestCaseName.it,
633
- withinDescribe: _utils2.TestCaseName.test
634
- }]
635
- }, {
636
- code: 'it.only("foo")',
637
- options: [{
638
- fn: _utils2.TestCaseName.it,
639
- withinDescribe: _utils2.TestCaseName.test
640
- }]
641
- }, {
642
- code: 'it.skip("foo")',
643
- options: [{
644
- fn: _utils2.TestCaseName.it,
645
- withinDescribe: _utils2.TestCaseName.test
646
- }]
647
- }, {
648
- code: 'it.concurrent("foo")',
649
- options: [{
650
- fn: _utils2.TestCaseName.it,
651
- withinDescribe: _utils2.TestCaseName.test
652
- }]
653
- }, {
654
- code: 'xit("foo")',
655
- options: [{
656
- fn: _utils2.TestCaseName.it,
657
- withinDescribe: _utils2.TestCaseName.test
658
- }]
659
- }, {
660
- code: '[1,2,3].forEach(() => { it("foo") })',
661
- options: [{
662
- fn: _utils2.TestCaseName.it,
663
- withinDescribe: _utils2.TestCaseName.test
664
- }]
665
- }],
666
- invalid: [{
667
- code: 'describe("suite", () => { it("foo") })',
668
- output: 'describe("suite", () => { test("foo") })',
669
- options: [{
670
- fn: _utils2.TestCaseName.it,
671
- withinDescribe: _utils2.TestCaseName.test
672
- }],
673
- errors: [{
674
- messageId: 'consistentMethodWithinDescribe',
675
- data: {
676
- testKeywordWithinDescribe: _utils2.TestCaseName.test,
677
- oppositeTestKeyword: _utils2.TestCaseName.it
678
- }
679
- }]
680
- }, {
681
- code: 'describe("suite", () => { it.only("foo") })',
682
- output: 'describe("suite", () => { test.only("foo") })',
683
- options: [{
684
- fn: _utils2.TestCaseName.it,
685
- withinDescribe: _utils2.TestCaseName.test
686
- }],
687
- errors: [{
688
- messageId: 'consistentMethodWithinDescribe',
689
- data: {
690
- testKeywordWithinDescribe: _utils2.TestCaseName.test,
691
- oppositeTestKeyword: _utils2.TestCaseName.it
692
- }
693
- }]
694
- }, {
695
- code: 'describe("suite", () => { xit("foo") })',
696
- output: 'describe("suite", () => { xtest("foo") })',
697
- options: [{
698
- fn: _utils2.TestCaseName.it,
699
- withinDescribe: _utils2.TestCaseName.test
700
- }],
701
- errors: [{
702
- messageId: 'consistentMethodWithinDescribe',
703
- data: {
704
- testKeywordWithinDescribe: _utils2.TestCaseName.test,
705
- oppositeTestKeyword: _utils2.TestCaseName.it
706
- }
707
- }]
708
- }, {
709
- code: 'describe("suite", () => { it.skip("foo") })',
710
- output: 'describe("suite", () => { test.skip("foo") })',
711
- options: [{
712
- fn: _utils2.TestCaseName.it,
713
- withinDescribe: _utils2.TestCaseName.test
714
- }],
715
- errors: [{
716
- messageId: 'consistentMethodWithinDescribe',
717
- data: {
718
- testKeywordWithinDescribe: _utils2.TestCaseName.test,
719
- oppositeTestKeyword: _utils2.TestCaseName.it
720
- }
721
- }]
722
- }, {
723
- code: 'describe("suite", () => { it.concurrent("foo") })',
724
- output: 'describe("suite", () => { test.concurrent("foo") })',
725
- options: [{
726
- fn: _utils2.TestCaseName.it,
727
- withinDescribe: _utils2.TestCaseName.test
728
- }],
729
- errors: [{
730
- messageId: 'consistentMethodWithinDescribe',
731
- data: {
732
- testKeywordWithinDescribe: _utils2.TestCaseName.test,
733
- oppositeTestKeyword: _utils2.TestCaseName.it
734
- }
735
- }]
736
- }]
737
- });
738
- ruleTester.run('consistent-test-it with fn=test and withinDescribe=test ', _consistentTestIt.default, {
739
- valid: [{
740
- code: 'describe("suite", () => { test("foo") })',
741
- options: [{
742
- fn: _utils2.TestCaseName.test,
743
- withinDescribe: _utils2.TestCaseName.test
744
- }]
745
- }, {
746
- code: 'test("foo");',
747
- options: [{
748
- fn: _utils2.TestCaseName.test,
749
- withinDescribe: _utils2.TestCaseName.test
750
- }]
751
- }],
752
- invalid: [{
753
- code: 'describe("suite", () => { it("foo") })',
754
- output: 'describe("suite", () => { test("foo") })',
755
- options: [{
756
- fn: _utils2.TestCaseName.test,
757
- withinDescribe: _utils2.TestCaseName.test
758
- }],
759
- errors: [{
760
- messageId: 'consistentMethodWithinDescribe',
761
- data: {
762
- testKeywordWithinDescribe: _utils2.TestCaseName.test,
763
- oppositeTestKeyword: _utils2.TestCaseName.it
764
- }
765
- }]
766
- }, {
767
- code: 'it("foo")',
768
- output: 'test("foo")',
769
- options: [{
770
- fn: _utils2.TestCaseName.test,
771
- withinDescribe: _utils2.TestCaseName.test
772
- }],
773
- errors: [{
774
- messageId: 'consistentMethod',
775
- data: {
776
- testKeyword: _utils2.TestCaseName.test,
777
- oppositeTestKeyword: _utils2.TestCaseName.it
778
- }
779
- }]
780
- }]
781
- });
782
- ruleTester.run('consistent-test-it with fn=it and withinDescribe=it ', _consistentTestIt.default, {
783
- valid: [{
784
- code: 'describe("suite", () => { it("foo") })',
785
- options: [{
786
- fn: _utils2.TestCaseName.it,
787
- withinDescribe: _utils2.TestCaseName.it
788
- }]
789
- }, {
790
- code: 'it("foo")',
791
- options: [{
792
- fn: _utils2.TestCaseName.it,
793
- withinDescribe: _utils2.TestCaseName.it
794
- }]
795
- }],
796
- invalid: [{
797
- code: 'describe("suite", () => { test("foo") })',
798
- output: 'describe("suite", () => { it("foo") })',
799
- options: [{
800
- fn: _utils2.TestCaseName.it,
801
- withinDescribe: _utils2.TestCaseName.it
802
- }],
803
- errors: [{
804
- messageId: 'consistentMethodWithinDescribe',
805
- data: {
806
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
807
- oppositeTestKeyword: _utils2.TestCaseName.test
808
- }
809
- }]
810
- }, {
811
- code: 'test("foo")',
812
- output: 'it("foo")',
813
- options: [{
814
- fn: _utils2.TestCaseName.it,
815
- withinDescribe: _utils2.TestCaseName.it
816
- }],
817
- errors: [{
818
- messageId: 'consistentMethod',
819
- data: {
820
- testKeyword: _utils2.TestCaseName.it,
821
- oppositeTestKeyword: _utils2.TestCaseName.test
822
- }
823
- }]
824
- }]
825
- });
826
- ruleTester.run('consistent-test-it defaults without config object', _consistentTestIt.default, {
827
- valid: [{
828
- code: 'test("foo")'
829
- }],
830
- invalid: [{
831
- code: 'describe("suite", () => { test("foo") })',
832
- output: 'describe("suite", () => { it("foo") })',
833
- errors: [{
834
- messageId: 'consistentMethodWithinDescribe',
835
- data: {
836
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
837
- oppositeTestKeyword: _utils2.TestCaseName.test
838
- }
839
- }]
840
- }]
841
- });
842
- ruleTester.run('consistent-test-it with withinDescribe=it', _consistentTestIt.default, {
843
- valid: [{
844
- code: 'test("foo")',
845
- options: [{
846
- withinDescribe: _utils2.TestCaseName.it
847
- }]
848
- }, {
849
- code: 'describe("suite", () => { it("foo") })',
850
- options: [{
851
- withinDescribe: _utils2.TestCaseName.it
852
- }]
853
- }],
854
- invalid: [{
855
- code: 'it("foo")',
856
- output: 'test("foo")',
857
- options: [{
858
- withinDescribe: _utils2.TestCaseName.it
859
- }],
860
- errors: [{
861
- messageId: 'consistentMethod',
862
- data: {
863
- testKeyword: _utils2.TestCaseName.test,
864
- oppositeTestKeyword: _utils2.TestCaseName.it
865
- }
866
- }]
867
- }, {
868
- code: 'describe("suite", () => { test("foo") })',
869
- output: 'describe("suite", () => { it("foo") })',
870
- options: [{
871
- withinDescribe: _utils2.TestCaseName.it
872
- }],
873
- errors: [{
874
- messageId: 'consistentMethodWithinDescribe',
875
- data: {
876
- testKeywordWithinDescribe: _utils2.TestCaseName.it,
877
- oppositeTestKeyword: _utils2.TestCaseName.test
878
- }
879
- }]
880
- }]
881
- });
882
- ruleTester.run('consistent-test-it with withinDescribe=test', _consistentTestIt.default, {
883
- valid: [{
884
- code: 'test("foo")',
885
- options: [{
886
- withinDescribe: _utils2.TestCaseName.test
887
- }]
888
- }, {
889
- code: 'describe("suite", () => { test("foo") })',
890
- options: [{
891
- withinDescribe: _utils2.TestCaseName.test
892
- }]
893
- }],
894
- invalid: [{
895
- code: 'it("foo")',
896
- output: 'test("foo")',
897
- options: [{
898
- withinDescribe: _utils2.TestCaseName.test
899
- }],
900
- errors: [{
901
- messageId: 'consistentMethod',
902
- data: {
903
- testKeyword: _utils2.TestCaseName.test,
904
- oppositeTestKeyword: _utils2.TestCaseName.it
905
- }
906
- }]
907
- }, {
908
- code: 'describe("suite", () => { it("foo") })',
909
- output: 'describe("suite", () => { test("foo") })',
910
- options: [{
911
- withinDescribe: _utils2.TestCaseName.test
912
- }],
913
- errors: [{
914
- messageId: 'consistentMethodWithinDescribe',
915
- data: {
916
- testKeywordWithinDescribe: _utils2.TestCaseName.test,
917
- oppositeTestKeyword: _utils2.TestCaseName.it
918
- }
919
- }]
920
- }]
921
- });