Skip to content

Commit b67e389

Browse files
authored
fix(no-disabled-tests): use jest function call parser for checking number of args (#1126)
1 parent 81d21c9 commit b67e389

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/rules/__tests__/no-disabled-tests.test.ts

+17
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ ruleTester.run('no-disabled-tests', rule, {
6060
return {}
6161
}
6262
`,
63+
{
64+
code: dedent`
65+
import { test } from './test-utils';
66+
67+
test('something');
68+
`,
69+
parserOptions: { sourceType: 'module' },
70+
},
6371
],
6472

6573
invalid: [
@@ -171,5 +179,14 @@ ruleTester.run('no-disabled-tests', rule, {
171179
code: 'describe("contains a call to pending", function () { pending() })',
172180
errors: [{ messageId: 'pendingSuite', column: 54, line: 1 }],
173181
},
182+
{
183+
code: dedent`
184+
import { test } from '@jest/globals';
185+
186+
test('something');
187+
`,
188+
parserOptions: { sourceType: 'module' },
189+
errors: [{ messageId: 'missingFunction', column: 1, line: 3 }],
190+
},
174191
],
175192
});

src/rules/no-disabled-tests.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ export default createRule({
3030
let testDepth = 0;
3131

3232
return {
33-
'CallExpression[callee.name=/^(it|test)$/][arguments.length<2]'(node) {
34-
context.report({ messageId: 'missingFunction', node });
35-
},
3633
CallExpression(node) {
3734
const jestFnCall = parseJestFnCall(node, context.getScope());
3835

@@ -46,6 +43,10 @@ export default createRule({
4643

4744
if (jestFnCall.type === 'test') {
4845
testDepth++;
46+
47+
if (node.arguments.length < 2) {
48+
context.report({ messageId: 'missingFunction', node });
49+
}
4950
}
5051

5152
if (

0 commit comments

Comments
 (0)