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.
- package/lib/rules/no-deprecated-functions.js +2 -2
- package/package.json +6 -6
- package/lib/processors/__tests__/snapshot-processor.test.js +0 -36
- package/lib/rules/__tests__/consistent-test-it.test.js +0 -921
- package/lib/rules/__tests__/expect-expect.test.js +0 -347
- package/lib/rules/__tests__/fixtures/class.ts +0 -13
- package/lib/rules/__tests__/fixtures/file.ts +0 -0
- package/lib/rules/__tests__/fixtures/foo.ts +0 -1
- package/lib/rules/__tests__/fixtures/indent/indent-invalid-fixture-1.js +0 -530
- package/lib/rules/__tests__/fixtures/indent/indent-valid-fixture-1.js +0 -530
- package/lib/rules/__tests__/fixtures/react.tsx +0 -0
- package/lib/rules/__tests__/fixtures/tsconfig-withmeta.json +0 -6
- package/lib/rules/__tests__/fixtures/tsconfig.json +0 -16
- package/lib/rules/__tests__/fixtures/unstrict/file.ts +0 -0
- package/lib/rules/__tests__/fixtures/unstrict/react.tsx +0 -0
- package/lib/rules/__tests__/fixtures/unstrict/tsconfig.json +0 -15
- package/lib/rules/__tests__/max-expects.test.js +0 -330
- package/lib/rules/__tests__/max-nested-describe.test.js +0 -247
- package/lib/rules/__tests__/no-alias-methods.test.js +0 -190
- package/lib/rules/__tests__/no-commented-out-tests.test.js +0 -213
- package/lib/rules/__tests__/no-conditional-expect.test.js +0 -696
- package/lib/rules/__tests__/no-conditional-in-test.test.js +0 -777
- package/lib/rules/__tests__/no-deprecated-functions.test.js +0 -119
- package/lib/rules/__tests__/no-disabled-tests.test.js +0 -241
- package/lib/rules/__tests__/no-done-callback.test.js +0 -424
- package/lib/rules/__tests__/no-duplicate-hooks.test.js +0 -469
- package/lib/rules/__tests__/no-export.test.js +0 -107
- package/lib/rules/__tests__/no-focused-tests.test.js +0 -373
- package/lib/rules/__tests__/no-hooks.test.js +0 -90
- package/lib/rules/__tests__/no-identical-title.test.js +0 -270
- package/lib/rules/__tests__/no-if.test.js +0 -787
- package/lib/rules/__tests__/no-interpolation-in-snapshots.test.js +0 -58
- package/lib/rules/__tests__/no-jasmine-globals.test.js +0 -206
- package/lib/rules/__tests__/no-large-snapshots.test.js +0 -237
- package/lib/rules/__tests__/no-mocks-import.test.js +0 -73
- package/lib/rules/__tests__/no-restricted-jest-methods.test.js +0 -103
- package/lib/rules/__tests__/no-restricted-matchers.test.js +0 -244
- package/lib/rules/__tests__/no-standalone-expect.test.js +0 -230
- package/lib/rules/__tests__/no-test-prefixes.test.js +0 -206
- package/lib/rules/__tests__/no-test-return-statement.test.js +0 -122
- package/lib/rules/__tests__/no-untyped-mock-factory.test.js +0 -149
- package/lib/rules/__tests__/prefer-called-with.test.js +0 -40
- package/lib/rules/__tests__/prefer-comparison-matcher.test.js +0 -200
- package/lib/rules/__tests__/prefer-each.test.js +0 -295
- package/lib/rules/__tests__/prefer-equality-matcher.test.js +0 -184
- package/lib/rules/__tests__/prefer-expect-assertions.test.js +0 -1437
- package/lib/rules/__tests__/prefer-expect-resolves.test.js +0 -96
- package/lib/rules/__tests__/prefer-hooks-in-order.test.js +0 -678
- package/lib/rules/__tests__/prefer-hooks-on-top.test.js +0 -218
- package/lib/rules/__tests__/prefer-lowercase-title.test.js +0 -619
- package/lib/rules/__tests__/prefer-mock-promise-shorthand.test.js +0 -360
- package/lib/rules/__tests__/prefer-snapshot-hint.test.js +0 -784
- package/lib/rules/__tests__/prefer-spy-on.test.js +0 -100
- package/lib/rules/__tests__/prefer-strict-equal.test.js +0 -46
- package/lib/rules/__tests__/prefer-to-be.test.js +0 -438
- package/lib/rules/__tests__/prefer-to-contain.test.js +0 -301
- package/lib/rules/__tests__/prefer-to-have-length.test.js +0 -99
- package/lib/rules/__tests__/prefer-todo.test.js +0 -78
- package/lib/rules/__tests__/require-hook.test.js +0 -403
- package/lib/rules/__tests__/require-to-throw-message.test.js +0 -108
- package/lib/rules/__tests__/require-top-level-describe.test.js +0 -236
- package/lib/rules/__tests__/test-utils.js +0 -11
- package/lib/rules/__tests__/unbound-method.test.js +0 -518
- package/lib/rules/__tests__/valid-describe-callback.test.js +0 -305
- package/lib/rules/__tests__/valid-expect-in-promise.test.js +0 -1583
- package/lib/rules/__tests__/valid-expect.test.js +0 -894
- package/lib/rules/__tests__/valid-title.test.js +0 -1147
- package/lib/rules/utils/__tests__/detectJestVersion.test.js +0 -221
- package/lib/rules/utils/__tests__/parseJestFnCall.test.js +0 -809
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _utils = require("@typescript-eslint/utils");
|
|
4
|
-
var _noRestrictedMatchers = _interopRequireDefault(require("../no-restricted-matchers"));
|
|
5
|
-
var _testUtils = require("./test-utils");
|
|
6
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
const ruleTester = new _utils.TSESLint.RuleTester({
|
|
8
|
-
parser: _testUtils.espreeParser,
|
|
9
|
-
parserOptions: {
|
|
10
|
-
ecmaVersion: 2017
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
ruleTester.run('no-restricted-matchers', _noRestrictedMatchers.default, {
|
|
14
|
-
valid: ['expect(a).toHaveBeenCalled()', 'expect(a).not.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);', {
|
|
15
|
-
code: 'expect(a).resolves',
|
|
16
|
-
options: [{
|
|
17
|
-
not: null
|
|
18
|
-
}]
|
|
19
|
-
}, {
|
|
20
|
-
code: 'expect(a).toBe(b)',
|
|
21
|
-
options: [{
|
|
22
|
-
'not.toBe': null
|
|
23
|
-
}]
|
|
24
|
-
}, {
|
|
25
|
-
code: 'expect(a).toBeUndefined(b)',
|
|
26
|
-
options: [{
|
|
27
|
-
toBe: null
|
|
28
|
-
}]
|
|
29
|
-
}, {
|
|
30
|
-
code: 'expect(a)["toBe"](b)',
|
|
31
|
-
options: [{
|
|
32
|
-
'not.toBe': null
|
|
33
|
-
}]
|
|
34
|
-
}, {
|
|
35
|
-
code: 'expect(a).resolves.not.toBe(b)',
|
|
36
|
-
options: [{
|
|
37
|
-
not: null
|
|
38
|
-
}]
|
|
39
|
-
}, {
|
|
40
|
-
code: 'expect(a).resolves.not.toBe(b)',
|
|
41
|
-
options: [{
|
|
42
|
-
'not.toBe': null
|
|
43
|
-
}]
|
|
44
|
-
}, {
|
|
45
|
-
code: "expect(uploadFileMock).resolves.toHaveBeenCalledWith('file.name')",
|
|
46
|
-
options: [{
|
|
47
|
-
'not.toHaveBeenCalledWith': 'Use not.toHaveBeenCalled instead'
|
|
48
|
-
}]
|
|
49
|
-
}, {
|
|
50
|
-
code: "expect(uploadFileMock).resolves.not.toHaveBeenCalledWith('file.name')",
|
|
51
|
-
options: [{
|
|
52
|
-
'not.toHaveBeenCalledWith': 'Use not.toHaveBeenCalled instead'
|
|
53
|
-
}]
|
|
54
|
-
}],
|
|
55
|
-
invalid: [{
|
|
56
|
-
code: 'expect(a).toBe(b)',
|
|
57
|
-
options: [{
|
|
58
|
-
toBe: null
|
|
59
|
-
}],
|
|
60
|
-
errors: [{
|
|
61
|
-
messageId: 'restrictedChain',
|
|
62
|
-
data: {
|
|
63
|
-
message: null,
|
|
64
|
-
restriction: 'toBe'
|
|
65
|
-
},
|
|
66
|
-
column: 11,
|
|
67
|
-
line: 1
|
|
68
|
-
}]
|
|
69
|
-
}, {
|
|
70
|
-
code: 'expect(a)["toBe"](b)',
|
|
71
|
-
options: [{
|
|
72
|
-
toBe: null
|
|
73
|
-
}],
|
|
74
|
-
errors: [{
|
|
75
|
-
messageId: 'restrictedChain',
|
|
76
|
-
data: {
|
|
77
|
-
message: null,
|
|
78
|
-
restriction: 'toBe'
|
|
79
|
-
},
|
|
80
|
-
column: 11,
|
|
81
|
-
line: 1
|
|
82
|
-
}]
|
|
83
|
-
}, {
|
|
84
|
-
code: 'expect(a).not[x]()',
|
|
85
|
-
options: [{
|
|
86
|
-
not: null
|
|
87
|
-
}],
|
|
88
|
-
errors: [{
|
|
89
|
-
messageId: 'restrictedChain',
|
|
90
|
-
data: {
|
|
91
|
-
message: null,
|
|
92
|
-
restriction: 'not'
|
|
93
|
-
},
|
|
94
|
-
column: 11,
|
|
95
|
-
line: 1
|
|
96
|
-
}]
|
|
97
|
-
}, {
|
|
98
|
-
code: 'expect(a).not.toBe(b)',
|
|
99
|
-
options: [{
|
|
100
|
-
not: null
|
|
101
|
-
}],
|
|
102
|
-
errors: [{
|
|
103
|
-
messageId: 'restrictedChain',
|
|
104
|
-
data: {
|
|
105
|
-
message: null,
|
|
106
|
-
restriction: 'not'
|
|
107
|
-
},
|
|
108
|
-
column: 11,
|
|
109
|
-
line: 1
|
|
110
|
-
}]
|
|
111
|
-
}, {
|
|
112
|
-
code: 'expect(a).resolves.toBe(b)',
|
|
113
|
-
options: [{
|
|
114
|
-
resolves: null
|
|
115
|
-
}],
|
|
116
|
-
errors: [{
|
|
117
|
-
messageId: 'restrictedChain',
|
|
118
|
-
data: {
|
|
119
|
-
message: null,
|
|
120
|
-
restriction: 'resolves'
|
|
121
|
-
},
|
|
122
|
-
column: 11,
|
|
123
|
-
line: 1
|
|
124
|
-
}]
|
|
125
|
-
}, {
|
|
126
|
-
code: 'expect(a).resolves.not.toBe(b)',
|
|
127
|
-
options: [{
|
|
128
|
-
resolves: null
|
|
129
|
-
}],
|
|
130
|
-
errors: [{
|
|
131
|
-
messageId: 'restrictedChain',
|
|
132
|
-
data: {
|
|
133
|
-
message: null,
|
|
134
|
-
restriction: 'resolves'
|
|
135
|
-
},
|
|
136
|
-
column: 11,
|
|
137
|
-
line: 1
|
|
138
|
-
}]
|
|
139
|
-
}, {
|
|
140
|
-
code: 'expect(a).resolves.not.toBe(b)',
|
|
141
|
-
options: [{
|
|
142
|
-
'resolves.not': null
|
|
143
|
-
}],
|
|
144
|
-
errors: [{
|
|
145
|
-
messageId: 'restrictedChain',
|
|
146
|
-
data: {
|
|
147
|
-
message: null,
|
|
148
|
-
restriction: 'resolves.not'
|
|
149
|
-
},
|
|
150
|
-
column: 11,
|
|
151
|
-
line: 1
|
|
152
|
-
}]
|
|
153
|
-
}, {
|
|
154
|
-
code: 'expect(a).not.toBe(b)',
|
|
155
|
-
options: [{
|
|
156
|
-
'not.toBe': null
|
|
157
|
-
}],
|
|
158
|
-
errors: [{
|
|
159
|
-
messageId: 'restrictedChain',
|
|
160
|
-
data: {
|
|
161
|
-
message: null,
|
|
162
|
-
restriction: 'not.toBe'
|
|
163
|
-
},
|
|
164
|
-
endColumn: 19,
|
|
165
|
-
column: 11,
|
|
166
|
-
line: 1
|
|
167
|
-
}]
|
|
168
|
-
}, {
|
|
169
|
-
code: 'expect(a).resolves.not.toBe(b)',
|
|
170
|
-
options: [{
|
|
171
|
-
'resolves.not.toBe': null
|
|
172
|
-
}],
|
|
173
|
-
errors: [{
|
|
174
|
-
messageId: 'restrictedChain',
|
|
175
|
-
data: {
|
|
176
|
-
message: null,
|
|
177
|
-
restriction: 'resolves.not.toBe'
|
|
178
|
-
},
|
|
179
|
-
endColumn: 28,
|
|
180
|
-
column: 11,
|
|
181
|
-
line: 1
|
|
182
|
-
}]
|
|
183
|
-
}, {
|
|
184
|
-
code: 'expect(a).toBe(b)',
|
|
185
|
-
options: [{
|
|
186
|
-
toBe: 'Prefer `toStrictEqual` instead'
|
|
187
|
-
}],
|
|
188
|
-
errors: [{
|
|
189
|
-
messageId: 'restrictedChainWithMessage',
|
|
190
|
-
data: {
|
|
191
|
-
message: 'Prefer `toStrictEqual` instead',
|
|
192
|
-
restriction: 'toBe'
|
|
193
|
-
},
|
|
194
|
-
column: 11,
|
|
195
|
-
line: 1
|
|
196
|
-
}]
|
|
197
|
-
}, {
|
|
198
|
-
code: `
|
|
199
|
-
test('some test', async () => {
|
|
200
|
-
await expect(Promise.resolve(1)).resolves.toBe(1);
|
|
201
|
-
});
|
|
202
|
-
`,
|
|
203
|
-
options: [{
|
|
204
|
-
resolves: 'Use `expect(await promise)` instead.'
|
|
205
|
-
}],
|
|
206
|
-
errors: [{
|
|
207
|
-
messageId: 'restrictedChainWithMessage',
|
|
208
|
-
data: {
|
|
209
|
-
message: 'Use `expect(await promise)` instead.',
|
|
210
|
-
restriction: 'resolves'
|
|
211
|
-
},
|
|
212
|
-
endColumn: 57,
|
|
213
|
-
column: 44
|
|
214
|
-
}]
|
|
215
|
-
}, {
|
|
216
|
-
code: 'expect(Promise.resolve({})).rejects.toBeFalsy()',
|
|
217
|
-
options: [{
|
|
218
|
-
'rejects.toBeFalsy': null
|
|
219
|
-
}],
|
|
220
|
-
errors: [{
|
|
221
|
-
messageId: 'restrictedChain',
|
|
222
|
-
data: {
|
|
223
|
-
message: null,
|
|
224
|
-
restriction: 'rejects.toBeFalsy'
|
|
225
|
-
},
|
|
226
|
-
endColumn: 46,
|
|
227
|
-
column: 29
|
|
228
|
-
}]
|
|
229
|
-
}, {
|
|
230
|
-
code: "expect(uploadFileMock).not.toHaveBeenCalledWith('file.name')",
|
|
231
|
-
options: [{
|
|
232
|
-
'not.toHaveBeenCalledWith': 'Use not.toHaveBeenCalled instead'
|
|
233
|
-
}],
|
|
234
|
-
errors: [{
|
|
235
|
-
messageId: 'restrictedChainWithMessage',
|
|
236
|
-
data: {
|
|
237
|
-
message: 'Use not.toHaveBeenCalled instead',
|
|
238
|
-
restriction: 'not.toHaveBeenCalledWith'
|
|
239
|
-
},
|
|
240
|
-
endColumn: 48,
|
|
241
|
-
column: 24
|
|
242
|
-
}]
|
|
243
|
-
}]
|
|
244
|
-
});
|
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _utils = require("@typescript-eslint/utils");
|
|
4
|
-
var _dedent = _interopRequireDefault(require("dedent"));
|
|
5
|
-
var _noStandaloneExpect = _interopRequireDefault(require("../no-standalone-expect"));
|
|
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('no-standalone-expect', _noStandaloneExpect.default, {
|
|
15
|
-
valid: ['expect.any(String)', 'expect.extend({})', 'describe("a test", () => { it("an it", () => {expect(1).toBe(1); }); });', 'describe("a test", () => { it("an it", () => { const func = () => { expect(1).toBe(1); }; }); });', 'describe("a test", () => { const func = () => { expect(1).toBe(1); }; });', 'describe("a test", () => { function func() { expect(1).toBe(1); }; });', 'describe("a test", () => { const func = function(){ expect(1).toBe(1); }; });', 'it("an it", () => expect(1).toBe(1))', 'const func = function(){ expect(1).toBe(1); };', 'const func = () => expect(1).toBe(1);', '{}', 'it.each([1, true])("trues", value => { expect(value).toBe(true); });', 'it.each([1, true])("trues", value => { expect(value).toBe(true); }); it("an it", () => { expect(1).toBe(1) });', (0, _dedent.default)`
|
|
16
|
-
it.each\`
|
|
17
|
-
num | value
|
|
18
|
-
\${1} | \${true}
|
|
19
|
-
\`('trues', ({ value }) => {
|
|
20
|
-
expect(value).toBe(true);
|
|
21
|
-
});
|
|
22
|
-
`, 'it.only("an only", value => { expect(value).toBe(true); });', 'it.concurrent("an concurrent", value => { expect(value).toBe(true); });', 'describe.each([1, true])("trues", value => { it("an it", () => expect(value).toBe(true) ); });', {
|
|
23
|
-
code: (0, _dedent.default)`
|
|
24
|
-
describe('scenario', () => {
|
|
25
|
-
const t = Math.random() ? it.only : it;
|
|
26
|
-
t('testing', () => expect(true));
|
|
27
|
-
});
|
|
28
|
-
`,
|
|
29
|
-
options: [{
|
|
30
|
-
additionalTestBlockFunctions: ['t']
|
|
31
|
-
}]
|
|
32
|
-
}, {
|
|
33
|
-
code: (0, _dedent.default)`
|
|
34
|
-
each([
|
|
35
|
-
[1, 1, 2],
|
|
36
|
-
[1, 2, 3],
|
|
37
|
-
[2, 1, 3],
|
|
38
|
-
]).test('returns the result of adding %d to %d', (a, b, expected) => {
|
|
39
|
-
expect(a + b).toBe(expected);
|
|
40
|
-
});
|
|
41
|
-
`,
|
|
42
|
-
options: [{
|
|
43
|
-
additionalTestBlockFunctions: ['each.test']
|
|
44
|
-
}]
|
|
45
|
-
}],
|
|
46
|
-
invalid: [{
|
|
47
|
-
code: "(() => {})('testing', () => expect(true).toBe(false))",
|
|
48
|
-
errors: [{
|
|
49
|
-
endColumn: 53,
|
|
50
|
-
column: 29,
|
|
51
|
-
messageId: 'unexpectedExpect'
|
|
52
|
-
}]
|
|
53
|
-
}, {
|
|
54
|
-
code: 'expect.hasAssertions()',
|
|
55
|
-
errors: [{
|
|
56
|
-
endColumn: 23,
|
|
57
|
-
column: 1,
|
|
58
|
-
messageId: 'unexpectedExpect'
|
|
59
|
-
}]
|
|
60
|
-
}, {
|
|
61
|
-
code: 'expect().hasAssertions()',
|
|
62
|
-
errors: [{
|
|
63
|
-
endColumn: 25,
|
|
64
|
-
column: 1,
|
|
65
|
-
messageId: 'unexpectedExpect'
|
|
66
|
-
}]
|
|
67
|
-
}, {
|
|
68
|
-
code: (0, _dedent.default)`
|
|
69
|
-
describe('scenario', () => {
|
|
70
|
-
const t = Math.random() ? it.only : it;
|
|
71
|
-
t('testing', () => expect(true).toBe(false));
|
|
72
|
-
});
|
|
73
|
-
`,
|
|
74
|
-
errors: [{
|
|
75
|
-
endColumn: 46,
|
|
76
|
-
column: 22,
|
|
77
|
-
messageId: 'unexpectedExpect'
|
|
78
|
-
}]
|
|
79
|
-
}, {
|
|
80
|
-
code: (0, _dedent.default)`
|
|
81
|
-
describe('scenario', () => {
|
|
82
|
-
const t = Math.random() ? it.only : it;
|
|
83
|
-
t('testing', () => expect(true).toBe(false));
|
|
84
|
-
});
|
|
85
|
-
`,
|
|
86
|
-
options: [{
|
|
87
|
-
additionalTestBlockFunctions: undefined
|
|
88
|
-
}],
|
|
89
|
-
errors: [{
|
|
90
|
-
endColumn: 46,
|
|
91
|
-
column: 22,
|
|
92
|
-
messageId: 'unexpectedExpect'
|
|
93
|
-
}]
|
|
94
|
-
}, {
|
|
95
|
-
code: (0, _dedent.default)`
|
|
96
|
-
each([
|
|
97
|
-
[1, 1, 2],
|
|
98
|
-
[1, 2, 3],
|
|
99
|
-
[2, 1, 3],
|
|
100
|
-
]).test('returns the result of adding %d to %d', (a, b, expected) => {
|
|
101
|
-
expect(a + b).toBe(expected);
|
|
102
|
-
});
|
|
103
|
-
`,
|
|
104
|
-
errors: [{
|
|
105
|
-
endColumn: 31,
|
|
106
|
-
column: 3,
|
|
107
|
-
messageId: 'unexpectedExpect'
|
|
108
|
-
}]
|
|
109
|
-
}, {
|
|
110
|
-
code: (0, _dedent.default)`
|
|
111
|
-
each([
|
|
112
|
-
[1, 1, 2],
|
|
113
|
-
[1, 2, 3],
|
|
114
|
-
[2, 1, 3],
|
|
115
|
-
]).test('returns the result of adding %d to %d', (a, b, expected) => {
|
|
116
|
-
expect(a + b).toBe(expected);
|
|
117
|
-
});
|
|
118
|
-
`,
|
|
119
|
-
options: [{
|
|
120
|
-
additionalTestBlockFunctions: ['each']
|
|
121
|
-
}],
|
|
122
|
-
errors: [{
|
|
123
|
-
endColumn: 31,
|
|
124
|
-
column: 3,
|
|
125
|
-
messageId: 'unexpectedExpect'
|
|
126
|
-
}]
|
|
127
|
-
}, {
|
|
128
|
-
code: (0, _dedent.default)`
|
|
129
|
-
each([
|
|
130
|
-
[1, 1, 2],
|
|
131
|
-
[1, 2, 3],
|
|
132
|
-
[2, 1, 3],
|
|
133
|
-
]).test('returns the result of adding %d to %d', (a, b, expected) => {
|
|
134
|
-
expect(a + b).toBe(expected);
|
|
135
|
-
});
|
|
136
|
-
`,
|
|
137
|
-
options: [{
|
|
138
|
-
additionalTestBlockFunctions: ['test']
|
|
139
|
-
}],
|
|
140
|
-
errors: [{
|
|
141
|
-
endColumn: 31,
|
|
142
|
-
column: 3,
|
|
143
|
-
messageId: 'unexpectedExpect'
|
|
144
|
-
}]
|
|
145
|
-
}, {
|
|
146
|
-
code: 'describe("a test", () => { expect(1).toBe(1); });',
|
|
147
|
-
errors: [{
|
|
148
|
-
endColumn: 45,
|
|
149
|
-
column: 28,
|
|
150
|
-
messageId: 'unexpectedExpect'
|
|
151
|
-
}]
|
|
152
|
-
}, {
|
|
153
|
-
code: 'describe("a test", () => expect(1).toBe(1));',
|
|
154
|
-
errors: [{
|
|
155
|
-
endColumn: 43,
|
|
156
|
-
column: 26,
|
|
157
|
-
messageId: 'unexpectedExpect'
|
|
158
|
-
}]
|
|
159
|
-
}, {
|
|
160
|
-
code: 'describe("a test", () => { const func = () => { expect(1).toBe(1); }; expect(1).toBe(1); });',
|
|
161
|
-
errors: [{
|
|
162
|
-
endColumn: 88,
|
|
163
|
-
column: 71,
|
|
164
|
-
messageId: 'unexpectedExpect'
|
|
165
|
-
}]
|
|
166
|
-
}, {
|
|
167
|
-
code: 'describe("a test", () => { it(() => { expect(1).toBe(1); }); expect(1).toBe(1); });',
|
|
168
|
-
errors: [{
|
|
169
|
-
endColumn: 80,
|
|
170
|
-
column: 63,
|
|
171
|
-
messageId: 'unexpectedExpect'
|
|
172
|
-
}]
|
|
173
|
-
}, {
|
|
174
|
-
code: 'expect(1).toBe(1);',
|
|
175
|
-
errors: [{
|
|
176
|
-
endColumn: 18,
|
|
177
|
-
column: 1,
|
|
178
|
-
messageId: 'unexpectedExpect'
|
|
179
|
-
}]
|
|
180
|
-
}, {
|
|
181
|
-
code: '{expect(1).toBe(1)}',
|
|
182
|
-
errors: [{
|
|
183
|
-
endColumn: 19,
|
|
184
|
-
column: 2,
|
|
185
|
-
messageId: 'unexpectedExpect'
|
|
186
|
-
}]
|
|
187
|
-
}, {
|
|
188
|
-
code: 'it.each([1, true])("trues", value => { expect(value).toBe(true); }); expect(1).toBe(1);',
|
|
189
|
-
errors: [{
|
|
190
|
-
endColumn: 87,
|
|
191
|
-
column: 70,
|
|
192
|
-
messageId: 'unexpectedExpect'
|
|
193
|
-
}]
|
|
194
|
-
}, {
|
|
195
|
-
code: 'describe.each([1, true])("trues", value => { expect(value).toBe(true); });',
|
|
196
|
-
errors: [{
|
|
197
|
-
endColumn: 70,
|
|
198
|
-
column: 46,
|
|
199
|
-
messageId: 'unexpectedExpect'
|
|
200
|
-
}]
|
|
201
|
-
}, {
|
|
202
|
-
code: (0, _dedent.default)`
|
|
203
|
-
import { expect as pleaseExpect } from '@jest/globals';
|
|
204
|
-
|
|
205
|
-
describe("a test", () => { pleaseExpect(1).toBe(1); });
|
|
206
|
-
`,
|
|
207
|
-
parserOptions: {
|
|
208
|
-
sourceType: 'module'
|
|
209
|
-
},
|
|
210
|
-
errors: [{
|
|
211
|
-
endColumn: 51,
|
|
212
|
-
column: 28,
|
|
213
|
-
messageId: 'unexpectedExpect'
|
|
214
|
-
}]
|
|
215
|
-
}, {
|
|
216
|
-
code: (0, _dedent.default)`
|
|
217
|
-
import { expect as pleaseExpect } from '@jest/globals';
|
|
218
|
-
|
|
219
|
-
beforeEach(() => pleaseExpect.hasAssertions());
|
|
220
|
-
`,
|
|
221
|
-
parserOptions: {
|
|
222
|
-
sourceType: 'module'
|
|
223
|
-
},
|
|
224
|
-
errors: [{
|
|
225
|
-
endColumn: 46,
|
|
226
|
-
column: 18,
|
|
227
|
-
messageId: 'unexpectedExpect'
|
|
228
|
-
}]
|
|
229
|
-
}]
|
|
230
|
-
});
|
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _utils = require("@typescript-eslint/utils");
|
|
4
|
-
var _dedent = _interopRequireDefault(require("dedent"));
|
|
5
|
-
var _noTestPrefixes = _interopRequireDefault(require("../no-test-prefixes"));
|
|
6
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7
|
-
const ruleTester = new _utils.TSESLint.RuleTester();
|
|
8
|
-
ruleTester.run('no-test-prefixes', _noTestPrefixes.default, {
|
|
9
|
-
valid: ['describe("foo", function () {})', 'it("foo", function () {})', 'it.concurrent("foo", function () {})', 'test("foo", function () {})', 'test.concurrent("foo", function () {})', 'describe.only("foo", function () {})', 'it.only("foo", function () {})', 'it.each()("foo", function () {})', {
|
|
10
|
-
code: 'it.each``("foo", function () {})',
|
|
11
|
-
parserOptions: {
|
|
12
|
-
ecmaVersion: 6
|
|
13
|
-
}
|
|
14
|
-
}, 'test.only("foo", function () {})', 'test.each()("foo", function () {})', {
|
|
15
|
-
code: 'test.each``("foo", function () {})',
|
|
16
|
-
parserOptions: {
|
|
17
|
-
ecmaVersion: 6
|
|
18
|
-
}
|
|
19
|
-
}, 'describe.skip("foo", function () {})', 'it.skip("foo", function () {})', 'test.skip("foo", function () {})', 'foo()', '[1,2,3].forEach()'],
|
|
20
|
-
invalid: [{
|
|
21
|
-
code: 'fdescribe("foo", function () {})',
|
|
22
|
-
output: 'describe.only("foo", function () {})',
|
|
23
|
-
errors: [{
|
|
24
|
-
messageId: 'usePreferredName',
|
|
25
|
-
data: {
|
|
26
|
-
preferredNodeName: 'describe.only'
|
|
27
|
-
},
|
|
28
|
-
column: 1,
|
|
29
|
-
line: 1
|
|
30
|
-
}]
|
|
31
|
-
}, {
|
|
32
|
-
code: 'xdescribe.each([])("foo", function () {})',
|
|
33
|
-
output: 'describe.skip.each([])("foo", function () {})',
|
|
34
|
-
errors: [{
|
|
35
|
-
messageId: 'usePreferredName',
|
|
36
|
-
data: {
|
|
37
|
-
preferredNodeName: 'describe.skip.each'
|
|
38
|
-
},
|
|
39
|
-
column: 1,
|
|
40
|
-
line: 1
|
|
41
|
-
}]
|
|
42
|
-
}, {
|
|
43
|
-
code: 'fit("foo", function () {})',
|
|
44
|
-
output: 'it.only("foo", function () {})',
|
|
45
|
-
errors: [{
|
|
46
|
-
messageId: 'usePreferredName',
|
|
47
|
-
data: {
|
|
48
|
-
preferredNodeName: 'it.only'
|
|
49
|
-
},
|
|
50
|
-
column: 1,
|
|
51
|
-
line: 1
|
|
52
|
-
}]
|
|
53
|
-
}, {
|
|
54
|
-
code: 'xdescribe("foo", function () {})',
|
|
55
|
-
output: 'describe.skip("foo", function () {})',
|
|
56
|
-
errors: [{
|
|
57
|
-
messageId: 'usePreferredName',
|
|
58
|
-
data: {
|
|
59
|
-
preferredNodeName: 'describe.skip'
|
|
60
|
-
},
|
|
61
|
-
column: 1,
|
|
62
|
-
line: 1
|
|
63
|
-
}]
|
|
64
|
-
}, {
|
|
65
|
-
code: 'xit("foo", function () {})',
|
|
66
|
-
output: 'it.skip("foo", function () {})',
|
|
67
|
-
errors: [{
|
|
68
|
-
messageId: 'usePreferredName',
|
|
69
|
-
data: {
|
|
70
|
-
preferredNodeName: 'it.skip'
|
|
71
|
-
},
|
|
72
|
-
column: 1,
|
|
73
|
-
line: 1
|
|
74
|
-
}]
|
|
75
|
-
}, {
|
|
76
|
-
code: 'xtest("foo", function () {})',
|
|
77
|
-
output: 'test.skip("foo", function () {})',
|
|
78
|
-
errors: [{
|
|
79
|
-
messageId: 'usePreferredName',
|
|
80
|
-
data: {
|
|
81
|
-
preferredNodeName: 'test.skip'
|
|
82
|
-
},
|
|
83
|
-
column: 1,
|
|
84
|
-
line: 1
|
|
85
|
-
}]
|
|
86
|
-
}, {
|
|
87
|
-
code: 'xit.each``("foo", function () {})',
|
|
88
|
-
output: 'it.skip.each``("foo", function () {})',
|
|
89
|
-
parserOptions: {
|
|
90
|
-
ecmaVersion: 6
|
|
91
|
-
},
|
|
92
|
-
errors: [{
|
|
93
|
-
messageId: 'usePreferredName',
|
|
94
|
-
data: {
|
|
95
|
-
preferredNodeName: 'it.skip.each'
|
|
96
|
-
},
|
|
97
|
-
column: 1,
|
|
98
|
-
line: 1
|
|
99
|
-
}]
|
|
100
|
-
}, {
|
|
101
|
-
code: 'xtest.each``("foo", function () {})',
|
|
102
|
-
output: 'test.skip.each``("foo", function () {})',
|
|
103
|
-
parserOptions: {
|
|
104
|
-
ecmaVersion: 6
|
|
105
|
-
},
|
|
106
|
-
errors: [{
|
|
107
|
-
messageId: 'usePreferredName',
|
|
108
|
-
data: {
|
|
109
|
-
preferredNodeName: 'test.skip.each'
|
|
110
|
-
},
|
|
111
|
-
column: 1,
|
|
112
|
-
line: 1
|
|
113
|
-
}]
|
|
114
|
-
}, {
|
|
115
|
-
code: 'xit.each([])("foo", function () {})',
|
|
116
|
-
output: 'it.skip.each([])("foo", function () {})',
|
|
117
|
-
errors: [{
|
|
118
|
-
messageId: 'usePreferredName',
|
|
119
|
-
data: {
|
|
120
|
-
preferredNodeName: 'it.skip.each'
|
|
121
|
-
},
|
|
122
|
-
column: 1,
|
|
123
|
-
line: 1
|
|
124
|
-
}]
|
|
125
|
-
}, {
|
|
126
|
-
code: 'xtest.each([])("foo", function () {})',
|
|
127
|
-
output: 'test.skip.each([])("foo", function () {})',
|
|
128
|
-
errors: [{
|
|
129
|
-
messageId: 'usePreferredName',
|
|
130
|
-
data: {
|
|
131
|
-
preferredNodeName: 'test.skip.each'
|
|
132
|
-
},
|
|
133
|
-
column: 1,
|
|
134
|
-
line: 1
|
|
135
|
-
}]
|
|
136
|
-
}, {
|
|
137
|
-
code: (0, _dedent.default)`
|
|
138
|
-
import { xit } from '@jest/globals';
|
|
139
|
-
|
|
140
|
-
xit("foo", function () {})
|
|
141
|
-
`,
|
|
142
|
-
output: (0, _dedent.default)`
|
|
143
|
-
import { xit } from '@jest/globals';
|
|
144
|
-
|
|
145
|
-
it.skip("foo", function () {})
|
|
146
|
-
`,
|
|
147
|
-
parserOptions: {
|
|
148
|
-
sourceType: 'module',
|
|
149
|
-
ecmaVersion: 2015
|
|
150
|
-
},
|
|
151
|
-
errors: [{
|
|
152
|
-
messageId: 'usePreferredName',
|
|
153
|
-
data: {
|
|
154
|
-
preferredNodeName: 'it.skip'
|
|
155
|
-
},
|
|
156
|
-
column: 1,
|
|
157
|
-
line: 3
|
|
158
|
-
}]
|
|
159
|
-
}, {
|
|
160
|
-
code: (0, _dedent.default)`
|
|
161
|
-
import { xit as skipThis } from '@jest/globals';
|
|
162
|
-
|
|
163
|
-
skipThis("foo", function () {})
|
|
164
|
-
`,
|
|
165
|
-
output: (0, _dedent.default)`
|
|
166
|
-
import { xit as skipThis } from '@jest/globals';
|
|
167
|
-
|
|
168
|
-
it.skip("foo", function () {})
|
|
169
|
-
`,
|
|
170
|
-
parserOptions: {
|
|
171
|
-
sourceType: 'module',
|
|
172
|
-
ecmaVersion: 2015
|
|
173
|
-
},
|
|
174
|
-
errors: [{
|
|
175
|
-
messageId: 'usePreferredName',
|
|
176
|
-
data: {
|
|
177
|
-
preferredNodeName: 'it.skip'
|
|
178
|
-
},
|
|
179
|
-
column: 1,
|
|
180
|
-
line: 3
|
|
181
|
-
}]
|
|
182
|
-
}, {
|
|
183
|
-
code: (0, _dedent.default)`
|
|
184
|
-
import { fit as onlyThis } from '@jest/globals';
|
|
185
|
-
|
|
186
|
-
onlyThis("foo", function () {})
|
|
187
|
-
`,
|
|
188
|
-
output: (0, _dedent.default)`
|
|
189
|
-
import { fit as onlyThis } from '@jest/globals';
|
|
190
|
-
|
|
191
|
-
it.only("foo", function () {})
|
|
192
|
-
`,
|
|
193
|
-
parserOptions: {
|
|
194
|
-
sourceType: 'module',
|
|
195
|
-
ecmaVersion: 2015
|
|
196
|
-
},
|
|
197
|
-
errors: [{
|
|
198
|
-
messageId: 'usePreferredName',
|
|
199
|
-
data: {
|
|
200
|
-
preferredNodeName: 'it.only'
|
|
201
|
-
},
|
|
202
|
-
column: 1,
|
|
203
|
-
line: 3
|
|
204
|
-
}]
|
|
205
|
-
}]
|
|
206
|
-
});
|