eslint-plugin-jest 27.2.2 → 27.2.3

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 (69) hide show
  1. package/lib/rules/no-deprecated-functions.js +2 -2
  2. package/package.json +6 -6
  3. package/lib/processors/__tests__/snapshot-processor.test.js +0 -36
  4. package/lib/rules/__tests__/consistent-test-it.test.js +0 -921
  5. package/lib/rules/__tests__/expect-expect.test.js +0 -347
  6. package/lib/rules/__tests__/fixtures/class.ts +0 -13
  7. package/lib/rules/__tests__/fixtures/file.ts +0 -0
  8. package/lib/rules/__tests__/fixtures/foo.ts +0 -1
  9. package/lib/rules/__tests__/fixtures/indent/indent-invalid-fixture-1.js +0 -530
  10. package/lib/rules/__tests__/fixtures/indent/indent-valid-fixture-1.js +0 -530
  11. package/lib/rules/__tests__/fixtures/react.tsx +0 -0
  12. package/lib/rules/__tests__/fixtures/tsconfig-withmeta.json +0 -6
  13. package/lib/rules/__tests__/fixtures/tsconfig.json +0 -16
  14. package/lib/rules/__tests__/fixtures/unstrict/file.ts +0 -0
  15. package/lib/rules/__tests__/fixtures/unstrict/react.tsx +0 -0
  16. package/lib/rules/__tests__/fixtures/unstrict/tsconfig.json +0 -15
  17. package/lib/rules/__tests__/max-expects.test.js +0 -330
  18. package/lib/rules/__tests__/max-nested-describe.test.js +0 -247
  19. package/lib/rules/__tests__/no-alias-methods.test.js +0 -190
  20. package/lib/rules/__tests__/no-commented-out-tests.test.js +0 -213
  21. package/lib/rules/__tests__/no-conditional-expect.test.js +0 -696
  22. package/lib/rules/__tests__/no-conditional-in-test.test.js +0 -777
  23. package/lib/rules/__tests__/no-deprecated-functions.test.js +0 -119
  24. package/lib/rules/__tests__/no-disabled-tests.test.js +0 -241
  25. package/lib/rules/__tests__/no-done-callback.test.js +0 -424
  26. package/lib/rules/__tests__/no-duplicate-hooks.test.js +0 -469
  27. package/lib/rules/__tests__/no-export.test.js +0 -107
  28. package/lib/rules/__tests__/no-focused-tests.test.js +0 -373
  29. package/lib/rules/__tests__/no-hooks.test.js +0 -90
  30. package/lib/rules/__tests__/no-identical-title.test.js +0 -270
  31. package/lib/rules/__tests__/no-if.test.js +0 -787
  32. package/lib/rules/__tests__/no-interpolation-in-snapshots.test.js +0 -58
  33. package/lib/rules/__tests__/no-jasmine-globals.test.js +0 -206
  34. package/lib/rules/__tests__/no-large-snapshots.test.js +0 -237
  35. package/lib/rules/__tests__/no-mocks-import.test.js +0 -73
  36. package/lib/rules/__tests__/no-restricted-jest-methods.test.js +0 -103
  37. package/lib/rules/__tests__/no-restricted-matchers.test.js +0 -244
  38. package/lib/rules/__tests__/no-standalone-expect.test.js +0 -230
  39. package/lib/rules/__tests__/no-test-prefixes.test.js +0 -206
  40. package/lib/rules/__tests__/no-test-return-statement.test.js +0 -122
  41. package/lib/rules/__tests__/no-untyped-mock-factory.test.js +0 -149
  42. package/lib/rules/__tests__/prefer-called-with.test.js +0 -40
  43. package/lib/rules/__tests__/prefer-comparison-matcher.test.js +0 -200
  44. package/lib/rules/__tests__/prefer-each.test.js +0 -295
  45. package/lib/rules/__tests__/prefer-equality-matcher.test.js +0 -184
  46. package/lib/rules/__tests__/prefer-expect-assertions.test.js +0 -1437
  47. package/lib/rules/__tests__/prefer-expect-resolves.test.js +0 -96
  48. package/lib/rules/__tests__/prefer-hooks-in-order.test.js +0 -678
  49. package/lib/rules/__tests__/prefer-hooks-on-top.test.js +0 -218
  50. package/lib/rules/__tests__/prefer-lowercase-title.test.js +0 -619
  51. package/lib/rules/__tests__/prefer-mock-promise-shorthand.test.js +0 -360
  52. package/lib/rules/__tests__/prefer-snapshot-hint.test.js +0 -784
  53. package/lib/rules/__tests__/prefer-spy-on.test.js +0 -100
  54. package/lib/rules/__tests__/prefer-strict-equal.test.js +0 -46
  55. package/lib/rules/__tests__/prefer-to-be.test.js +0 -438
  56. package/lib/rules/__tests__/prefer-to-contain.test.js +0 -301
  57. package/lib/rules/__tests__/prefer-to-have-length.test.js +0 -99
  58. package/lib/rules/__tests__/prefer-todo.test.js +0 -78
  59. package/lib/rules/__tests__/require-hook.test.js +0 -403
  60. package/lib/rules/__tests__/require-to-throw-message.test.js +0 -108
  61. package/lib/rules/__tests__/require-top-level-describe.test.js +0 -236
  62. package/lib/rules/__tests__/test-utils.js +0 -11
  63. package/lib/rules/__tests__/unbound-method.test.js +0 -518
  64. package/lib/rules/__tests__/valid-describe-callback.test.js +0 -305
  65. package/lib/rules/__tests__/valid-expect-in-promise.test.js +0 -1583
  66. package/lib/rules/__tests__/valid-expect.test.js +0 -894
  67. package/lib/rules/__tests__/valid-title.test.js +0 -1147
  68. package/lib/rules/utils/__tests__/detectJestVersion.test.js +0 -221
  69. package/lib/rules/utils/__tests__/parseJestFnCall.test.js +0 -809
@@ -1,1147 +0,0 @@
1
- "use strict";
2
-
3
- var _utils = require("@typescript-eslint/utils");
4
- var _dedent = _interopRequireDefault(require("dedent"));
5
- var _validTitle = _interopRequireDefault(require("../valid-title"));
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: 2017
12
- }
13
- });
14
- ruleTester.run('disallowedWords option', _validTitle.default, {
15
- valid: ['describe("the correct way to properly handle all the things", () => {});', 'test("that all is as it should be", () => {});', {
16
- code: 'it("correctly sets the value", () => {});',
17
- options: [{
18
- ignoreTypeOfDescribeName: false,
19
- disallowedWords: ['correct']
20
- }]
21
- }, {
22
- code: 'it("correctly sets the value", () => {});',
23
- options: [{
24
- disallowedWords: undefined
25
- }]
26
- }],
27
- invalid: [{
28
- code: 'test("the correct way to properly handle all things", () => {});',
29
- options: [{
30
- disallowedWords: ['correct', 'properly', 'all']
31
- }],
32
- errors: [{
33
- messageId: 'disallowedWord',
34
- data: {
35
- word: 'correct'
36
- },
37
- column: 6,
38
- line: 1
39
- }]
40
- }, {
41
- code: 'describe("the correct way to do things", function () {})',
42
- options: [{
43
- disallowedWords: ['correct']
44
- }],
45
- errors: [{
46
- messageId: 'disallowedWord',
47
- data: {
48
- word: 'correct'
49
- },
50
- column: 10,
51
- line: 1
52
- }]
53
- }, {
54
- code: 'it("has ALL the things", () => {})',
55
- options: [{
56
- disallowedWords: ['all']
57
- }],
58
- errors: [{
59
- messageId: 'disallowedWord',
60
- data: {
61
- word: 'ALL'
62
- },
63
- column: 4,
64
- line: 1
65
- }]
66
- }, {
67
- code: 'xdescribe("every single one of them", function () {})',
68
- options: [{
69
- disallowedWords: ['every']
70
- }],
71
- errors: [{
72
- messageId: 'disallowedWord',
73
- data: {
74
- word: 'every'
75
- },
76
- column: 11,
77
- line: 1
78
- }]
79
- }, {
80
- code: "describe('Very Descriptive Title Goes Here', function () {})",
81
- options: [{
82
- disallowedWords: ['descriptive']
83
- }],
84
- errors: [{
85
- messageId: 'disallowedWord',
86
- data: {
87
- word: 'Descriptive'
88
- },
89
- column: 10,
90
- line: 1
91
- }]
92
- }, {
93
- code: 'test(`that the value is set properly`, function () {})',
94
- options: [{
95
- disallowedWords: ['properly']
96
- }],
97
- errors: [{
98
- messageId: 'disallowedWord',
99
- data: {
100
- word: 'properly'
101
- },
102
- column: 6,
103
- line: 1
104
- }]
105
- }]
106
- });
107
- ruleTester.run('mustMatch & mustNotMatch options', _validTitle.default, {
108
- valid: ['describe("the correct way to properly handle all the things", () => {});', 'test("that all is as it should be", () => {});', {
109
- code: 'it("correctly sets the value", () => {});',
110
- options: [{
111
- mustMatch: {}
112
- }]
113
- }, {
114
- code: 'it("correctly sets the value", () => {});',
115
- options: [{
116
- mustMatch: / /u.source
117
- }]
118
- }, {
119
- code: 'it("correctly sets the value", () => {});',
120
- options: [{
121
- mustMatch: [/ /u.source]
122
- }]
123
- }, {
124
- code: 'it("correctly sets the value #unit", () => {});',
125
- options: [{
126
- mustMatch: /#(?:unit|integration|e2e)/u.source
127
- }]
128
- }, {
129
- code: 'it("correctly sets the value", () => {});',
130
- options: [{
131
- mustMatch: /^[^#]+$|(?:#(?:unit|e2e))/u.source
132
- }]
133
- }, {
134
- code: 'it("correctly sets the value", () => {});',
135
- options: [{
136
- mustMatch: {
137
- test: /#(?:unit|integration|e2e)/u.source
138
- }
139
- }]
140
- }, {
141
- code: (0, _dedent.default)`
142
- describe('things to test', () => {
143
- describe('unit tests #unit', () => {
144
- it('is true', () => {
145
- expect(true).toBe(true);
146
- });
147
- });
148
-
149
- describe('e2e tests #e2e', () => {
150
- it('is another test #jest4life', () => {});
151
- });
152
- });
153
- `,
154
- options: [{
155
- mustMatch: {
156
- test: /^[^#]+$|(?:#(?:unit|e2e))/u.source
157
- }
158
- }]
159
- }],
160
- invalid: [{
161
- code: (0, _dedent.default)`
162
- describe('things to test', () => {
163
- describe('unit tests #unit', () => {
164
- it('is true', () => {
165
- expect(true).toBe(true);
166
- });
167
- });
168
-
169
- describe('e2e tests #e4e', () => {
170
- it('is another test #e2e #jest4life', () => {});
171
- });
172
- });
173
- `,
174
- options: [{
175
- mustNotMatch: /(?:#(?!unit|e2e))\w+/u.source,
176
- mustMatch: /^[^#]+$|(?:#(?:unit|e2e))/u.source
177
- }],
178
- errors: [{
179
- messageId: 'mustNotMatch',
180
- data: {
181
- jestFunctionName: 'describe',
182
- pattern: /(?:#(?!unit|e2e))\w+/u
183
- },
184
- column: 12,
185
- line: 8
186
- }, {
187
- messageId: 'mustNotMatch',
188
- data: {
189
- jestFunctionName: 'it',
190
- pattern: /(?:#(?!unit|e2e))\w+/u
191
- },
192
- column: 8,
193
- line: 9
194
- }]
195
- }, {
196
- code: (0, _dedent.default)`
197
- import { describe, describe as context, it as thisTest } from '@jest/globals';
198
-
199
- describe('things to test', () => {
200
- context('unit tests #unit', () => {
201
- thisTest('is true', () => {
202
- expect(true).toBe(true);
203
- });
204
- });
205
-
206
- context('e2e tests #e4e', () => {
207
- thisTest('is another test #e2e #jest4life', () => {});
208
- });
209
- });
210
- `,
211
- options: [{
212
- mustNotMatch: /(?:#(?!unit|e2e))\w+/u.source,
213
- mustMatch: /^[^#]+$|(?:#(?:unit|e2e))/u.source
214
- }],
215
- parserOptions: {
216
- sourceType: 'module'
217
- },
218
- errors: [{
219
- messageId: 'mustNotMatch',
220
- data: {
221
- jestFunctionName: 'describe',
222
- pattern: /(?:#(?!unit|e2e))\w+/u
223
- },
224
- column: 11,
225
- line: 10
226
- }, {
227
- messageId: 'mustNotMatch',
228
- data: {
229
- jestFunctionName: 'it',
230
- pattern: /(?:#(?!unit|e2e))\w+/u
231
- },
232
- column: 14,
233
- line: 11
234
- }]
235
- }, {
236
- code: (0, _dedent.default)`
237
- describe('things to test', () => {
238
- describe('unit tests #unit', () => {
239
- it('is true', () => {
240
- expect(true).toBe(true);
241
- });
242
- });
243
-
244
- describe('e2e tests #e4e', () => {
245
- it('is another test #e2e #jest4life', () => {});
246
- });
247
- });
248
- `,
249
- options: [{
250
- mustNotMatch: [/(?:#(?!unit|e2e))\w+/u.source, 'Please include "#unit" or "#e2e" in titles'],
251
- mustMatch: [/^[^#]+$|(?:#(?:unit|e2e))/u.source, 'Please include "#unit" or "#e2e" in titles']
252
- }],
253
- errors: [{
254
- messageId: 'mustNotMatchCustom',
255
- data: {
256
- jestFunctionName: 'describe',
257
- pattern: /(?:#(?!unit|e2e))\w+/u,
258
- message: 'Please include "#unit" or "#e2e" in titles'
259
- },
260
- column: 12,
261
- line: 8
262
- }, {
263
- messageId: 'mustNotMatchCustom',
264
- data: {
265
- jestFunctionName: 'it',
266
- pattern: /(?:#(?!unit|e2e))\w+/u,
267
- message: 'Please include "#unit" or "#e2e" in titles'
268
- },
269
- column: 8,
270
- line: 9
271
- }]
272
- }, {
273
- code: (0, _dedent.default)`
274
- describe('things to test', () => {
275
- describe('unit tests #unit', () => {
276
- it('is true', () => {
277
- expect(true).toBe(true);
278
- });
279
- });
280
-
281
- describe('e2e tests #e4e', () => {
282
- it('is another test #e2e #jest4life', () => {});
283
- });
284
- });
285
- `,
286
- options: [{
287
- mustNotMatch: {
288
- describe: [/(?:#(?!unit|e2e))\w+/u.source]
289
- },
290
- mustMatch: {
291
- describe: /^[^#]+$|(?:#(?:unit|e2e))/u.source
292
- }
293
- }],
294
- errors: [{
295
- messageId: 'mustNotMatch',
296
- data: {
297
- jestFunctionName: 'describe',
298
- pattern: /(?:#(?!unit|e2e))\w+/u
299
- },
300
- column: 12,
301
- line: 8
302
- }]
303
- }, {
304
- code: (0, _dedent.default)`
305
- describe('things to test', () => {
306
- describe('unit tests #unit', () => {
307
- it('is true', () => {
308
- expect(true).toBe(true);
309
- });
310
- });
311
-
312
- describe('e2e tests #e4e', () => {
313
- it('is another test #e2e #jest4life', () => {});
314
- });
315
- });
316
- `,
317
- options: [{
318
- mustNotMatch: {
319
- describe: [/(?:#(?!unit|e2e))\w+/u.source, 'Please include "#unit" or "#e2e" in describe titles']
320
- },
321
- mustMatch: {
322
- describe: /^[^#]+$|(?:#(?:unit|e2e))/u.source
323
- }
324
- }],
325
- errors: [{
326
- messageId: 'mustNotMatchCustom',
327
- data: {
328
- jestFunctionName: 'describe',
329
- pattern: /(?:#(?!unit|e2e))\w+/u,
330
- message: 'Please include "#unit" or "#e2e" in describe titles'
331
- },
332
- column: 12,
333
- line: 8
334
- }]
335
- }, {
336
- code: (0, _dedent.default)`
337
- describe('things to test', () => {
338
- describe('unit tests #unit', () => {
339
- it('is true', () => {
340
- expect(true).toBe(true);
341
- });
342
- });
343
-
344
- describe('e2e tests #e4e', () => {
345
- it('is another test #e2e #jest4life', () => {});
346
- });
347
- });
348
- `,
349
- options: [{
350
- mustNotMatch: {
351
- describe: /(?:#(?!unit|e2e))\w+/u.source
352
- },
353
- mustMatch: {
354
- it: /^[^#]+$|(?:#(?:unit|e2e))/u.source
355
- }
356
- }],
357
- errors: [{
358
- messageId: 'mustNotMatch',
359
- data: {
360
- jestFunctionName: 'describe',
361
- pattern: /(?:#(?!unit|e2e))\w+/u
362
- },
363
- column: 12,
364
- line: 8
365
- }]
366
- }, {
367
- code: (0, _dedent.default)`
368
- describe('things to test', () => {
369
- describe('unit tests #unit', () => {
370
- it('is true #jest4life', () => {
371
- expect(true).toBe(true);
372
- });
373
- });
374
-
375
- describe('e2e tests #e4e', () => {
376
- it('is another test #e2e #jest4life', () => {});
377
- });
378
- });
379
- `,
380
- options: [{
381
- mustNotMatch: {
382
- describe: [/(?:#(?!unit|e2e))\w+/u.source, 'Please include "#unit" or "#e2e" in describe titles']
383
- },
384
- mustMatch: {
385
- it: [/^[^#]+$|(?:#(?:unit|e2e))/u.source, 'Please include "#unit" or "#e2e" in it titles']
386
- }
387
- }],
388
- errors: [{
389
- messageId: 'mustMatchCustom',
390
- data: {
391
- jestFunctionName: 'it',
392
- pattern: /^[^#]+$|(?:#(?:unit|e2e))/u,
393
- message: 'Please include "#unit" or "#e2e" in it titles'
394
- },
395
- column: 8,
396
- line: 3
397
- }, {
398
- messageId: 'mustNotMatchCustom',
399
- data: {
400
- jestFunctionName: 'describe',
401
- pattern: /(?:#(?!unit|e2e))\w+/u,
402
- message: 'Please include "#unit" or "#e2e" in describe titles'
403
- },
404
- column: 12,
405
- line: 8
406
- }]
407
- }, {
408
- code: 'test("the correct way to properly handle all things", () => {});',
409
- options: [{
410
- mustMatch: /#(?:unit|integration|e2e)/u.source
411
- }],
412
- errors: [{
413
- messageId: 'mustMatch',
414
- data: {
415
- jestFunctionName: 'test',
416
- pattern: /#(?:unit|integration|e2e)/u
417
- },
418
- column: 6,
419
- line: 1
420
- }]
421
- }, {
422
- code: 'describe("the test", () => {});',
423
- options: [{
424
- mustMatch: {
425
- describe: /#(?:unit|integration|e2e)/u.source
426
- }
427
- }],
428
- errors: [{
429
- messageId: 'mustMatch',
430
- data: {
431
- jestFunctionName: 'describe',
432
- pattern: /#(?:unit|integration|e2e)/u
433
- },
434
- column: 10,
435
- line: 1
436
- }]
437
- }, {
438
- code: 'xdescribe("the test", () => {});',
439
- options: [{
440
- mustMatch: {
441
- describe: /#(?:unit|integration|e2e)/u.source
442
- }
443
- }],
444
- errors: [{
445
- messageId: 'mustMatch',
446
- data: {
447
- jestFunctionName: 'describe',
448
- pattern: /#(?:unit|integration|e2e)/u
449
- },
450
- column: 11,
451
- line: 1
452
- }]
453
- }, {
454
- code: 'describe.skip("the test", () => {});',
455
- options: [{
456
- mustMatch: {
457
- describe: /#(?:unit|integration|e2e)/u.source
458
- }
459
- }],
460
- errors: [{
461
- messageId: 'mustMatch',
462
- data: {
463
- jestFunctionName: 'describe',
464
- pattern: /#(?:unit|integration|e2e)/u
465
- },
466
- column: 15,
467
- line: 1
468
- }]
469
- }]
470
- });
471
- ruleTester.run('title-must-be-string', _validTitle.default, {
472
- valid: ['it("is a string", () => {});', 'it("is" + " a " + " string", () => {});', 'it(1 + " + " + 1, () => {});', 'test("is a string", () => {});', 'xtest("is a string", () => {});', 'xtest(`${myFunc} is a string`, () => {});', 'describe("is a string", () => {});', 'describe.skip("is a string", () => {});', 'describe.skip(`${myFunc} is a string`, () => {});', 'fdescribe("is a string", () => {});', {
473
- code: 'describe(String(/.+/), () => {});',
474
- options: [{
475
- ignoreTypeOfDescribeName: true
476
- }]
477
- }, {
478
- code: 'describe(myFunction, () => {});',
479
- options: [{
480
- ignoreTypeOfDescribeName: true
481
- }]
482
- }, {
483
- code: 'xdescribe(skipFunction, () => {});',
484
- options: [{
485
- ignoreTypeOfDescribeName: true,
486
- disallowedWords: []
487
- }]
488
- }],
489
- invalid: [{
490
- code: 'it.each([])(1, () => {});',
491
- errors: [{
492
- messageId: 'titleMustBeString',
493
- column: 13,
494
- line: 1
495
- }]
496
- }, {
497
- code: 'it.skip.each([])(1, () => {});',
498
- errors: [{
499
- messageId: 'titleMustBeString',
500
- column: 18,
501
- line: 1
502
- }]
503
- }, {
504
- code: 'it.skip.each``(1, () => {});',
505
- errors: [{
506
- messageId: 'titleMustBeString',
507
- column: 16,
508
- line: 1
509
- }]
510
- }, {
511
- code: 'it(123, () => {});',
512
- errors: [{
513
- messageId: 'titleMustBeString',
514
- column: 4,
515
- line: 1
516
- }]
517
- }, {
518
- code: 'it.concurrent(123, () => {});',
519
- errors: [{
520
- messageId: 'titleMustBeString',
521
- column: 15,
522
- line: 1
523
- }]
524
- }, {
525
- code: 'it(1 + 2 + 3, () => {});',
526
- errors: [{
527
- messageId: 'titleMustBeString',
528
- column: 4,
529
- line: 1
530
- }]
531
- }, {
532
- code: 'it.concurrent(1 + 2 + 3, () => {});',
533
- errors: [{
534
- messageId: 'titleMustBeString',
535
- column: 15,
536
- line: 1
537
- }]
538
- }, {
539
- code: 'test.skip(123, () => {});',
540
- options: [{
541
- ignoreTypeOfDescribeName: true
542
- }],
543
- errors: [{
544
- messageId: 'titleMustBeString',
545
- column: 11,
546
- line: 1
547
- }]
548
- }, {
549
- code: 'describe(String(/.+/), () => {});',
550
- errors: [{
551
- messageId: 'titleMustBeString',
552
- column: 10,
553
- line: 1
554
- }]
555
- }, {
556
- code: 'describe(myFunction, () => 1);',
557
- options: [{
558
- ignoreTypeOfDescribeName: false
559
- }],
560
- errors: [{
561
- messageId: 'titleMustBeString',
562
- column: 10,
563
- line: 1
564
- }]
565
- }, {
566
- code: 'describe(myFunction, () => {});',
567
- errors: [{
568
- messageId: 'titleMustBeString',
569
- column: 10,
570
- line: 1
571
- }]
572
- }, {
573
- code: 'xdescribe(myFunction, () => {});',
574
- errors: [{
575
- messageId: 'titleMustBeString',
576
- column: 11,
577
- line: 1
578
- }]
579
- }, {
580
- code: 'describe(6, function () {})',
581
- errors: [{
582
- messageId: 'titleMustBeString',
583
- column: 10,
584
- line: 1
585
- }]
586
- }, {
587
- code: 'describe.skip(123, () => {});',
588
- errors: [{
589
- messageId: 'titleMustBeString',
590
- column: 15,
591
- line: 1
592
- }]
593
- }]
594
- });
595
- ruleTester.run('no-empty-title', _validTitle.default, {
596
- valid: ['describe()', 'someFn("", function () {})', 'describe("foo", function () {})', 'describe("foo", function () { it("bar", function () {}) })', 'test("foo", function () {})', 'test.concurrent("foo", function () {})', 'test(`foo`, function () {})', 'test.concurrent(`foo`, function () {})', 'test(`${foo}`, function () {})', 'test.concurrent(`${foo}`, function () {})', "it('foo', function () {})", 'it.each([])()', "it.concurrent('foo', function () {})", "xdescribe('foo', function () {})", "xit('foo', function () {})", "xtest('foo', function () {})"],
597
- invalid: [{
598
- code: 'describe("", function () {})',
599
- errors: [{
600
- messageId: 'emptyTitle',
601
- column: 1,
602
- line: 1,
603
- data: {
604
- jestFunctionName: 'describe'
605
- }
606
- }]
607
- }, {
608
- code: (0, _dedent.default)`
609
- describe('foo', () => {
610
- it('', () => {});
611
- });
612
- `,
613
- errors: [{
614
- messageId: 'emptyTitle',
615
- column: 3,
616
- line: 2,
617
- data: {
618
- jestFunctionName: 'test'
619
- }
620
- }]
621
- }, {
622
- code: 'it("", function () {})',
623
- errors: [{
624
- messageId: 'emptyTitle',
625
- column: 1,
626
- line: 1,
627
- data: {
628
- jestFunctionName: 'test'
629
- }
630
- }]
631
- }, {
632
- code: 'it.concurrent("", function () {})',
633
- errors: [{
634
- messageId: 'emptyTitle',
635
- column: 1,
636
- line: 1,
637
- data: {
638
- jestFunctionName: 'test'
639
- }
640
- }]
641
- }, {
642
- code: 'test("", function () {})',
643
- errors: [{
644
- messageId: 'emptyTitle',
645
- column: 1,
646
- line: 1,
647
- data: {
648
- jestFunctionName: 'test'
649
- }
650
- }]
651
- }, {
652
- code: 'test.concurrent("", function () {})',
653
- errors: [{
654
- messageId: 'emptyTitle',
655
- column: 1,
656
- line: 1,
657
- data: {
658
- jestFunctionName: 'test'
659
- }
660
- }]
661
- }, {
662
- code: 'test(``, function () {})',
663
- errors: [{
664
- messageId: 'emptyTitle',
665
- column: 1,
666
- line: 1,
667
- data: {
668
- jestFunctionName: 'test'
669
- }
670
- }]
671
- }, {
672
- code: 'test.concurrent(``, function () {})',
673
- errors: [{
674
- messageId: 'emptyTitle',
675
- column: 1,
676
- line: 1,
677
- data: {
678
- jestFunctionName: 'test'
679
- }
680
- }]
681
- }, {
682
- code: "xdescribe('', () => {})",
683
- errors: [{
684
- messageId: 'emptyTitle',
685
- column: 1,
686
- line: 1,
687
- data: {
688
- jestFunctionName: 'describe'
689
- }
690
- }]
691
- }, {
692
- code: "xit('', () => {})",
693
- errors: [{
694
- messageId: 'emptyTitle',
695
- column: 1,
696
- line: 1,
697
- data: {
698
- jestFunctionName: 'test'
699
- }
700
- }]
701
- }, {
702
- code: "xtest('', () => {})",
703
- errors: [{
704
- messageId: 'emptyTitle',
705
- column: 1,
706
- line: 1,
707
- data: {
708
- jestFunctionName: 'test'
709
- }
710
- }]
711
- }]
712
- });
713
- ruleTester.run('no-accidental-space', _validTitle.default, {
714
- valid: ['it()', 'it.concurrent()', 'describe()', 'it.each()()', 'describe("foo", function () {})', 'fdescribe("foo", function () {})', 'xdescribe("foo", function () {})', 'it("foo", function () {})', 'it.concurrent("foo", function () {})', 'fit("foo", function () {})', 'fit.concurrent("foo", function () {})', 'xit("foo", function () {})', 'test("foo", function () {})', 'test.concurrent("foo", function () {})', 'xtest("foo", function () {})', 'xtest(`foo`, function () {})', 'someFn("foo", function () {})', (0, _dedent.default)`
715
- describe('foo', () => {
716
- it('bar', () => {})
717
- })
718
- `],
719
- invalid: [{
720
- code: 'describe(" foo", function () {})',
721
- output: 'describe("foo", function () {})',
722
- errors: [{
723
- messageId: 'accidentalSpace',
724
- column: 10,
725
- line: 1
726
- }]
727
- }, {
728
- code: 'describe.each()(" foo", function () {})',
729
- output: 'describe.each()("foo", function () {})',
730
- errors: [{
731
- messageId: 'accidentalSpace',
732
- column: 17,
733
- line: 1
734
- }]
735
- }, {
736
- code: 'describe.only.each()(" foo", function () {})',
737
- output: 'describe.only.each()("foo", function () {})',
738
- errors: [{
739
- messageId: 'accidentalSpace',
740
- column: 22,
741
- line: 1
742
- }]
743
- }, {
744
- code: 'describe(" foo foe fum", function () {})',
745
- output: 'describe("foo foe fum", function () {})',
746
- errors: [{
747
- messageId: 'accidentalSpace',
748
- column: 10,
749
- line: 1
750
- }]
751
- }, {
752
- code: 'describe("foo foe fum ", function () {})',
753
- output: 'describe("foo foe fum", function () {})',
754
- errors: [{
755
- messageId: 'accidentalSpace',
756
- column: 10,
757
- line: 1
758
- }]
759
- }, {
760
- code: 'fdescribe(" foo", function () {})',
761
- output: 'fdescribe("foo", function () {})',
762
- errors: [{
763
- messageId: 'accidentalSpace',
764
- column: 11,
765
- line: 1
766
- }]
767
- }, {
768
- code: "fdescribe(' foo', function () {})",
769
- output: "fdescribe('foo', function () {})",
770
- errors: [{
771
- messageId: 'accidentalSpace',
772
- column: 11,
773
- line: 1
774
- }]
775
- }, {
776
- code: 'xdescribe(" foo", function () {})',
777
- output: 'xdescribe("foo", function () {})',
778
- errors: [{
779
- messageId: 'accidentalSpace',
780
- column: 11,
781
- line: 1
782
- }]
783
- }, {
784
- code: 'it(" foo", function () {})',
785
- output: 'it("foo", function () {})',
786
- errors: [{
787
- messageId: 'accidentalSpace',
788
- column: 4,
789
- line: 1
790
- }]
791
- }, {
792
- code: 'it.concurrent(" foo", function () {})',
793
- output: 'it.concurrent("foo", function () {})',
794
- errors: [{
795
- messageId: 'accidentalSpace',
796
- column: 15,
797
- line: 1
798
- }]
799
- }, {
800
- code: 'fit(" foo", function () {})',
801
- output: 'fit("foo", function () {})',
802
- errors: [{
803
- messageId: 'accidentalSpace',
804
- column: 5,
805
- line: 1
806
- }]
807
- }, {
808
- code: 'it.skip(" foo", function () {})',
809
- output: 'it.skip("foo", function () {})',
810
- errors: [{
811
- messageId: 'accidentalSpace',
812
- column: 9,
813
- line: 1
814
- }]
815
- }, {
816
- code: 'fit("foo ", function () {})',
817
- output: 'fit("foo", function () {})',
818
- errors: [{
819
- messageId: 'accidentalSpace',
820
- column: 5,
821
- line: 1
822
- }]
823
- }, {
824
- code: 'it.skip("foo ", function () {})',
825
- output: 'it.skip("foo", function () {})',
826
- errors: [{
827
- messageId: 'accidentalSpace',
828
- column: 9,
829
- line: 1
830
- }]
831
- }, {
832
- code: (0, _dedent.default)`
833
- import { test as testThat } from '@jest/globals';
834
-
835
- testThat('foo works ', () => {});
836
- `,
837
- output: (0, _dedent.default)`
838
- import { test as testThat } from '@jest/globals';
839
-
840
- testThat('foo works', () => {});
841
- `,
842
- parserOptions: {
843
- sourceType: 'module'
844
- },
845
- errors: [{
846
- messageId: 'accidentalSpace',
847
- column: 10,
848
- line: 3
849
- }]
850
- }, {
851
- code: 'xit(" foo", function () {})',
852
- output: 'xit("foo", function () {})',
853
- errors: [{
854
- messageId: 'accidentalSpace',
855
- column: 5,
856
- line: 1
857
- }]
858
- }, {
859
- code: 'test(" foo", function () {})',
860
- output: 'test("foo", function () {})',
861
- errors: [{
862
- messageId: 'accidentalSpace',
863
- column: 6,
864
- line: 1
865
- }]
866
- }, {
867
- code: 'test.concurrent(" foo", function () {})',
868
- output: 'test.concurrent("foo", function () {})',
869
- errors: [{
870
- messageId: 'accidentalSpace',
871
- column: 17,
872
- line: 1
873
- }]
874
- }, {
875
- code: 'test(` foo`, function () {})',
876
- output: 'test(`foo`, function () {})',
877
- errors: [{
878
- messageId: 'accidentalSpace',
879
- column: 6,
880
- line: 1
881
- }]
882
- }, {
883
- code: 'test.concurrent(` foo`, function () {})',
884
- output: 'test.concurrent(`foo`, function () {})',
885
- errors: [{
886
- messageId: 'accidentalSpace',
887
- column: 17,
888
- line: 1
889
- }]
890
- }, {
891
- code: 'test(` foo bar bang`, function () {})',
892
- output: 'test(`foo bar bang`, function () {})',
893
- errors: [{
894
- messageId: 'accidentalSpace',
895
- column: 6,
896
- line: 1
897
- }]
898
- }, {
899
- code: 'test.concurrent(` foo bar bang`, function () {})',
900
- output: 'test.concurrent(`foo bar bang`, function () {})',
901
- errors: [{
902
- messageId: 'accidentalSpace',
903
- column: 17,
904
- line: 1
905
- }]
906
- }, {
907
- code: 'test(` foo bar bang `, function () {})',
908
- output: 'test(`foo bar bang`, function () {})',
909
- errors: [{
910
- messageId: 'accidentalSpace',
911
- column: 6,
912
- line: 1
913
- }]
914
- }, {
915
- code: 'test.concurrent(` foo bar bang `, function () {})',
916
- output: 'test.concurrent(`foo bar bang`, function () {})',
917
- errors: [{
918
- messageId: 'accidentalSpace',
919
- column: 17,
920
- line: 1
921
- }]
922
- }, {
923
- code: 'xtest(" foo", function () {})',
924
- output: 'xtest("foo", function () {})',
925
- errors: [{
926
- messageId: 'accidentalSpace',
927
- column: 7,
928
- line: 1
929
- }]
930
- }, {
931
- code: 'xtest(" foo ", function () {})',
932
- output: 'xtest("foo", function () {})',
933
- errors: [{
934
- messageId: 'accidentalSpace',
935
- column: 7,
936
- line: 1
937
- }]
938
- }, {
939
- code: (0, _dedent.default)`
940
- describe(' foo', () => {
941
- it('bar', () => {})
942
- })
943
- `,
944
- output: (0, _dedent.default)`
945
- describe('foo', () => {
946
- it('bar', () => {})
947
- })
948
- `,
949
- errors: [{
950
- messageId: 'accidentalSpace',
951
- column: 10,
952
- line: 1
953
- }]
954
- }, {
955
- code: (0, _dedent.default)`
956
- describe('foo', () => {
957
- it(' bar', () => {})
958
- })
959
- `,
960
- output: (0, _dedent.default)`
961
- describe('foo', () => {
962
- it('bar', () => {})
963
- })
964
- `,
965
- errors: [{
966
- messageId: 'accidentalSpace',
967
- column: 6,
968
- line: 2
969
- }]
970
- }]
971
- });
972
- ruleTester.run('no-duplicate-prefix ft describe', _validTitle.default, {
973
- valid: ['describe("foo", function () {})', 'fdescribe("foo", function () {})', 'xdescribe("foo", function () {})', 'xdescribe(`foo`, function () {})'],
974
- invalid: [{
975
- code: 'describe("describe foo", function () {})',
976
- output: 'describe("foo", function () {})',
977
- errors: [{
978
- messageId: 'duplicatePrefix',
979
- column: 10,
980
- line: 1
981
- }]
982
- }, {
983
- code: 'fdescribe("describe foo", function () {})',
984
- output: 'fdescribe("foo", function () {})',
985
- errors: [{
986
- messageId: 'duplicatePrefix',
987
- column: 11,
988
- line: 1
989
- }]
990
- }, {
991
- code: 'xdescribe("describe foo", function () {})',
992
- output: 'xdescribe("foo", function () {})',
993
- errors: [{
994
- messageId: 'duplicatePrefix',
995
- column: 11,
996
- line: 1
997
- }]
998
- }, {
999
- code: "describe('describe foo', function () {})",
1000
- output: "describe('foo', function () {})",
1001
- errors: [{
1002
- messageId: 'duplicatePrefix',
1003
- column: 10,
1004
- line: 1
1005
- }]
1006
- }, {
1007
- code: 'fdescribe(`describe foo`, function () {})',
1008
- output: 'fdescribe(`foo`, function () {})',
1009
- errors: [{
1010
- messageId: 'duplicatePrefix',
1011
- column: 11,
1012
- line: 1
1013
- }]
1014
- }]
1015
- });
1016
- ruleTester.run('no-duplicate-prefix ft test', _validTitle.default, {
1017
- valid: ['test("foo", function () {})', "test('foo', function () {})", 'xtest("foo", function () {})', 'xtest(`foo`, function () {})', 'test("foo test", function () {})', 'xtest("foo test", function () {})'],
1018
- invalid: [{
1019
- code: 'test("test foo", function () {})',
1020
- output: 'test("foo", function () {})',
1021
- errors: [{
1022
- messageId: 'duplicatePrefix',
1023
- column: 6,
1024
- line: 1
1025
- }]
1026
- }, {
1027
- code: 'xtest("test foo", function () {})',
1028
- output: 'xtest("foo", function () {})',
1029
- errors: [{
1030
- messageId: 'duplicatePrefix',
1031
- column: 7,
1032
- line: 1
1033
- }]
1034
- }, {
1035
- code: 'test(`test foo`, function () {})',
1036
- output: 'test(`foo`, function () {})',
1037
- errors: [{
1038
- messageId: 'duplicatePrefix',
1039
- column: 6,
1040
- line: 1
1041
- }]
1042
- }, {
1043
- code: 'test(`test foo test`, function () {})',
1044
- output: 'test(`foo test`, function () {})',
1045
- errors: [{
1046
- messageId: 'duplicatePrefix',
1047
- column: 6,
1048
- line: 1
1049
- }]
1050
- }]
1051
- });
1052
- ruleTester.run('no-duplicate-prefix ft it', _validTitle.default, {
1053
- valid: ['it("foo", function () {})', 'fit("foo", function () {})', 'xit("foo", function () {})', 'xit(`foo`, function () {})', 'it("foos it correctly", function () {})'],
1054
- invalid: [{
1055
- code: 'it("it foo", function () {})',
1056
- output: 'it("foo", function () {})',
1057
- errors: [{
1058
- messageId: 'duplicatePrefix',
1059
- column: 4,
1060
- line: 1
1061
- }]
1062
- }, {
1063
- code: 'fit("it foo", function () {})',
1064
- output: 'fit("foo", function () {})',
1065
- errors: [{
1066
- messageId: 'duplicatePrefix',
1067
- column: 5,
1068
- line: 1
1069
- }]
1070
- }, {
1071
- code: 'xit("it foo", function () {})',
1072
- output: 'xit("foo", function () {})',
1073
- errors: [{
1074
- messageId: 'duplicatePrefix',
1075
- column: 5,
1076
- line: 1
1077
- }]
1078
- }, {
1079
- code: 'it("it foos it correctly", function () {})',
1080
- output: 'it("foos it correctly", function () {})',
1081
- errors: [{
1082
- messageId: 'duplicatePrefix',
1083
- column: 4,
1084
- line: 1
1085
- }]
1086
- }]
1087
- });
1088
- ruleTester.run('no-duplicate-prefix ft nested', _validTitle.default, {
1089
- valid: [(0, _dedent.default)`
1090
- describe('foo', () => {
1091
- it('bar', () => {})
1092
- })
1093
- `, (0, _dedent.default)`
1094
- describe('foo', () => {
1095
- it('describes things correctly', () => {})
1096
- })
1097
- `],
1098
- invalid: [{
1099
- code: (0, _dedent.default)`
1100
- describe('describe foo', () => {
1101
- it('bar', () => {})
1102
- })
1103
- `,
1104
- output: (0, _dedent.default)`
1105
- describe('foo', () => {
1106
- it('bar', () => {})
1107
- })
1108
- `,
1109
- errors: [{
1110
- messageId: 'duplicatePrefix',
1111
- column: 10,
1112
- line: 1
1113
- }]
1114
- }, {
1115
- code: (0, _dedent.default)`
1116
- describe('describe foo', () => {
1117
- it('describes things correctly', () => {})
1118
- })
1119
- `,
1120
- output: (0, _dedent.default)`
1121
- describe('foo', () => {
1122
- it('describes things correctly', () => {})
1123
- })
1124
- `,
1125
- errors: [{
1126
- messageId: 'duplicatePrefix',
1127
- column: 10,
1128
- line: 1
1129
- }]
1130
- }, {
1131
- code: (0, _dedent.default)`
1132
- describe('foo', () => {
1133
- it('it bar', () => {})
1134
- })
1135
- `,
1136
- output: (0, _dedent.default)`
1137
- describe('foo', () => {
1138
- it('bar', () => {})
1139
- })
1140
- `,
1141
- errors: [{
1142
- messageId: 'duplicatePrefix',
1143
- column: 6,
1144
- line: 2
1145
- }]
1146
- }]
1147
- });