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,190 +0,0 @@
1
- "use strict";
2
-
3
- var _utils = require("@typescript-eslint/utils");
4
- var _noAliasMethods = _interopRequireDefault(require("../no-alias-methods"));
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
- const ruleTester = new _utils.TSESLint.RuleTester();
7
- ruleTester.run('no-alias-methods', _noAliasMethods.default, {
8
- valid: ['expect(a).toHaveBeenCalled()', 'expect(a).toHaveBeenCalledTimes()', 'expect(a).toHaveBeenCalledWith()', 'expect(a).toHaveBeenLastCalledWith()', 'expect(a).toHaveBeenNthCalledWith()', 'expect(a).toHaveReturned()', 'expect(a).toHaveReturnedTimes()', 'expect(a).toHaveReturnedWith()', 'expect(a).toHaveLastReturnedWith()', 'expect(a).toHaveNthReturnedWith()', 'expect(a).toThrow()', 'expect(a).rejects;', 'expect(a);'],
9
- invalid: [{
10
- code: 'expect(a).toBeCalled()',
11
- output: 'expect(a).toHaveBeenCalled()',
12
- errors: [{
13
- messageId: 'replaceAlias',
14
- data: {
15
- alias: 'toBeCalled',
16
- canonical: 'toHaveBeenCalled'
17
- },
18
- column: 11,
19
- line: 1
20
- }]
21
- }, {
22
- code: 'expect(a).toBeCalledTimes()',
23
- output: 'expect(a).toHaveBeenCalledTimes()',
24
- errors: [{
25
- messageId: 'replaceAlias',
26
- data: {
27
- alias: 'toBeCalledTimes',
28
- canonical: 'toHaveBeenCalledTimes'
29
- },
30
- column: 11,
31
- line: 1
32
- }]
33
- }, {
34
- code: 'expect(a).toBeCalledWith()',
35
- output: 'expect(a).toHaveBeenCalledWith()',
36
- errors: [{
37
- messageId: 'replaceAlias',
38
- data: {
39
- alias: 'toBeCalledWith',
40
- canonical: 'toHaveBeenCalledWith'
41
- },
42
- column: 11,
43
- line: 1
44
- }]
45
- }, {
46
- code: 'expect(a).lastCalledWith()',
47
- output: 'expect(a).toHaveBeenLastCalledWith()',
48
- errors: [{
49
- messageId: 'replaceAlias',
50
- data: {
51
- alias: 'lastCalledWith',
52
- canonical: 'toHaveBeenLastCalledWith'
53
- },
54
- column: 11,
55
- line: 1
56
- }]
57
- }, {
58
- code: 'expect(a).nthCalledWith()',
59
- output: 'expect(a).toHaveBeenNthCalledWith()',
60
- errors: [{
61
- messageId: 'replaceAlias',
62
- data: {
63
- alias: 'nthCalledWith',
64
- canonical: 'toHaveBeenNthCalledWith'
65
- },
66
- column: 11,
67
- line: 1
68
- }]
69
- }, {
70
- code: 'expect(a).toReturn()',
71
- output: 'expect(a).toHaveReturned()',
72
- errors: [{
73
- messageId: 'replaceAlias',
74
- data: {
75
- alias: 'toReturn',
76
- canonical: 'toHaveReturned'
77
- },
78
- column: 11,
79
- line: 1
80
- }]
81
- }, {
82
- code: 'expect(a).toReturnTimes()',
83
- output: 'expect(a).toHaveReturnedTimes()',
84
- errors: [{
85
- messageId: 'replaceAlias',
86
- data: {
87
- alias: 'toReturnTimes',
88
- canonical: 'toHaveReturnedTimes'
89
- },
90
- column: 11,
91
- line: 1
92
- }]
93
- }, {
94
- code: 'expect(a).toReturnWith()',
95
- output: 'expect(a).toHaveReturnedWith()',
96
- errors: [{
97
- messageId: 'replaceAlias',
98
- data: {
99
- alias: 'toReturnWith',
100
- canonical: 'toHaveReturnedWith'
101
- },
102
- column: 11,
103
- line: 1
104
- }]
105
- }, {
106
- code: 'expect(a).lastReturnedWith()',
107
- output: 'expect(a).toHaveLastReturnedWith()',
108
- errors: [{
109
- messageId: 'replaceAlias',
110
- data: {
111
- alias: 'lastReturnedWith',
112
- canonical: 'toHaveLastReturnedWith'
113
- },
114
- column: 11,
115
- line: 1
116
- }]
117
- }, {
118
- code: 'expect(a).nthReturnedWith()',
119
- output: 'expect(a).toHaveNthReturnedWith()',
120
- errors: [{
121
- messageId: 'replaceAlias',
122
- data: {
123
- alias: 'nthReturnedWith',
124
- canonical: 'toHaveNthReturnedWith'
125
- },
126
- column: 11,
127
- line: 1
128
- }]
129
- }, {
130
- code: 'expect(a).toThrowError()',
131
- output: 'expect(a).toThrow()',
132
- errors: [{
133
- messageId: 'replaceAlias',
134
- data: {
135
- alias: 'toThrowError',
136
- canonical: 'toThrow'
137
- },
138
- column: 11,
139
- line: 1
140
- }]
141
- }, {
142
- code: 'expect(a).resolves.toThrowError()',
143
- output: 'expect(a).resolves.toThrow()',
144
- errors: [{
145
- messageId: 'replaceAlias',
146
- data: {
147
- alias: 'toThrowError',
148
- canonical: 'toThrow'
149
- },
150
- column: 20,
151
- line: 1
152
- }]
153
- }, {
154
- code: 'expect(a).rejects.toThrowError()',
155
- output: 'expect(a).rejects.toThrow()',
156
- errors: [{
157
- messageId: 'replaceAlias',
158
- data: {
159
- alias: 'toThrowError',
160
- canonical: 'toThrow'
161
- },
162
- column: 19,
163
- line: 1
164
- }]
165
- }, {
166
- code: 'expect(a).not.toThrowError()',
167
- output: 'expect(a).not.toThrow()',
168
- errors: [{
169
- messageId: 'replaceAlias',
170
- data: {
171
- alias: 'toThrowError',
172
- canonical: 'toThrow'
173
- },
174
- column: 15,
175
- line: 1
176
- }]
177
- }, {
178
- code: 'expect(a).not["toThrowError"]()',
179
- output: "expect(a).not['toThrow']()",
180
- errors: [{
181
- messageId: 'replaceAlias',
182
- data: {
183
- alias: 'toThrowError',
184
- canonical: 'toThrow'
185
- },
186
- column: 15,
187
- line: 1
188
- }]
189
- }]
190
- });
@@ -1,213 +0,0 @@
1
- "use strict";
2
-
3
- var _utils = require("@typescript-eslint/utils");
4
- var _dedent = _interopRequireDefault(require("dedent"));
5
- var _noCommentedOutTests = _interopRequireDefault(require("../no-commented-out-tests"));
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
- sourceType: 'module'
13
- }
14
- });
15
- ruleTester.run('no-commented-out-tests', _noCommentedOutTests.default, {
16
- valid: ['// foo("bar", function () {})', 'describe("foo", function () {})', 'it("foo", function () {})', 'describe.only("foo", function () {})', 'it.only("foo", function () {})', 'it.concurrent("foo", function () {})', 'test("foo", function () {})', 'test.only("foo", function () {})', 'test.concurrent("foo", function () {})', 'var appliedSkip = describe.skip; appliedSkip.apply(describe)', 'var calledSkip = it.skip; calledSkip.call(it)', '({ f: function () {} }).f()', '(a || b).f()', 'itHappensToStartWithIt()', 'testSomething()', '// latest(dates)', '// TODO: unify with Git implementation from Shipit (?)', '#!/usr/bin/env node', (0, _dedent.default)`
17
- import { pending } from "actions"
18
-
19
- test("foo", () => {
20
- expect(pending()).toEqual({})
21
- })
22
- `, (0, _dedent.default)`
23
- const { pending } = require("actions")
24
-
25
- test("foo", () => {
26
- expect(pending()).toEqual({})
27
- })
28
- `, (0, _dedent.default)`
29
- test("foo", () => {
30
- const pending = getPending()
31
- expect(pending()).toEqual({})
32
- })
33
- `, (0, _dedent.default)`
34
- test("foo", () => {
35
- expect(pending()).toEqual({})
36
- })
37
-
38
- function pending() {
39
- return {}
40
- }
41
- `],
42
- invalid: [{
43
- code: '// describe("foo", function () {})',
44
- errors: [{
45
- messageId: 'commentedTests',
46
- column: 1,
47
- line: 1
48
- }]
49
- }, {
50
- code: '// describe["skip"]("foo", function () {})',
51
- errors: [{
52
- messageId: 'commentedTests',
53
- column: 1,
54
- line: 1
55
- }]
56
- }, {
57
- code: '// describe[\'skip\']("foo", function () {})',
58
- errors: [{
59
- messageId: 'commentedTests',
60
- column: 1,
61
- line: 1
62
- }]
63
- }, {
64
- code: '// it.skip("foo", function () {})',
65
- errors: [{
66
- messageId: 'commentedTests',
67
- column: 1,
68
- line: 1
69
- }]
70
- }, {
71
- code: '// it.only("foo", function () {})',
72
- errors: [{
73
- messageId: 'commentedTests',
74
- column: 1,
75
- line: 1
76
- }]
77
- }, {
78
- code: '// it.concurrent("foo", function () {})',
79
- errors: [{
80
- messageId: 'commentedTests',
81
- column: 1,
82
- line: 1
83
- }]
84
- }, {
85
- code: '// it["skip"]("foo", function () {})',
86
- errors: [{
87
- messageId: 'commentedTests',
88
- column: 1,
89
- line: 1
90
- }]
91
- }, {
92
- code: '// test.skip("foo", function () {})',
93
- errors: [{
94
- messageId: 'commentedTests',
95
- column: 1,
96
- line: 1
97
- }]
98
- }, {
99
- code: '// test.concurrent("foo", function () {})',
100
- errors: [{
101
- messageId: 'commentedTests',
102
- column: 1,
103
- line: 1
104
- }]
105
- }, {
106
- code: '// test["skip"]("foo", function () {})',
107
- errors: [{
108
- messageId: 'commentedTests',
109
- column: 1,
110
- line: 1
111
- }]
112
- }, {
113
- code: '// xdescribe("foo", function () {})',
114
- errors: [{
115
- messageId: 'commentedTests',
116
- column: 1,
117
- line: 1
118
- }]
119
- }, {
120
- code: '// xit("foo", function () {})',
121
- errors: [{
122
- messageId: 'commentedTests',
123
- column: 1,
124
- line: 1
125
- }]
126
- }, {
127
- code: '// fit("foo", function () {})',
128
- errors: [{
129
- messageId: 'commentedTests',
130
- column: 1,
131
- line: 1
132
- }]
133
- }, {
134
- code: '// xtest("foo", function () {})',
135
- errors: [{
136
- messageId: 'commentedTests',
137
- column: 1,
138
- line: 1
139
- }]
140
- }, {
141
- code: (0, _dedent.default)`
142
- // test(
143
- // "foo", function () {}
144
- // )
145
- `,
146
- errors: [{
147
- messageId: 'commentedTests',
148
- column: 1,
149
- line: 1
150
- }]
151
- }, {
152
- code: (0, _dedent.default)`
153
- /* test
154
- (
155
- "foo", function () {}
156
- )
157
- */
158
- `,
159
- errors: [{
160
- messageId: 'commentedTests',
161
- column: 1,
162
- line: 1
163
- }]
164
- }, {
165
- code: '// it("has title but no callback")',
166
- errors: [{
167
- messageId: 'commentedTests',
168
- column: 1,
169
- line: 1
170
- }]
171
- }, {
172
- code: '// it()',
173
- errors: [{
174
- messageId: 'commentedTests',
175
- column: 1,
176
- line: 1
177
- }]
178
- }, {
179
- code: '// test.someNewMethodThatMightBeAddedInTheFuture()',
180
- errors: [{
181
- messageId: 'commentedTests',
182
- column: 1,
183
- line: 1
184
- }]
185
- }, {
186
- code: '// test["someNewMethodThatMightBeAddedInTheFuture"]()',
187
- errors: [{
188
- messageId: 'commentedTests',
189
- column: 1,
190
- line: 1
191
- }]
192
- }, {
193
- code: '// test("has title but no callback")',
194
- errors: [{
195
- messageId: 'commentedTests',
196
- column: 1,
197
- line: 1
198
- }]
199
- }, {
200
- code: (0, _dedent.default)`
201
- foo()
202
- /*
203
- describe("has title but no callback", () => {})
204
- */
205
- bar()
206
- `,
207
- errors: [{
208
- messageId: 'commentedTests',
209
- column: 1,
210
- line: 2
211
- }]
212
- }]
213
- });