Skip to content

Commit 35e37a1

Browse files
fix(expect-expert): report on test function identifier rather than body (#337)
* fix(expect-expert): report on test function identifier rather than body * Prettier
1 parent c067ad2 commit 35e37a1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/rules/expect-expect.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,33 @@ runRuleTester('expect-expect', rule, {
55
invalid: [
66
{
77
code: 'test("should fail", () => {});',
8-
errors: [{ messageId: 'noAssertions' }],
8+
errors: [{ messageId: 'noAssertions', type: 'Identifier' }],
99
},
1010
{
1111
code: 'test.skip("should fail", () => {});',
12-
errors: [{ messageId: 'noAssertions' }],
12+
errors: [{ messageId: 'noAssertions', type: 'MemberExpression' }],
1313
},
1414
{
1515
code: javascript`
1616
test('should fail', async ({ page }) => {
1717
await assertCustomCondition(page)
1818
})
1919
`,
20-
errors: [{ messageId: 'noAssertions' }],
20+
errors: [{ messageId: 'noAssertions', type: 'Identifier' }],
2121
},
2222
{
2323
code: javascript`
2424
test('should fail', async ({ page }) => {
2525
await assertCustomCondition(page)
2626
})
2727
`,
28-
errors: [{ messageId: 'noAssertions' }],
28+
errors: [{ messageId: 'noAssertions', type: 'Identifier' }],
2929
name: 'Custom assert function',
3030
options: [{ assertFunctionNames: ['wayComplexCustomCondition'] }],
3131
},
3232
{
3333
code: 'it("should pass", () => hi(true).toBeDefined())',
34-
errors: [{ messageId: 'noAssertions' }],
34+
errors: [{ messageId: 'noAssertions', type: 'Identifier' }],
3535
name: 'Global aliases',
3636
settings: {
3737
playwright: {

src/rules/expect-expect.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default createRule({
4040
},
4141
'Program:exit'() {
4242
unchecked.forEach((node) => {
43-
context.report({ messageId: 'noAssertions', node })
43+
context.report({ messageId: 'noAssertions', node: node.callee })
4444
})
4545
},
4646
}

0 commit comments

Comments
 (0)