Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(expect-expert): report on test function identifier rather than body #337

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/rules/expect-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@ runRuleTester('expect-expect', rule, {
invalid: [
{
code: 'test("should fail", () => {});',
errors: [{ messageId: 'noAssertions' }],
errors: [{ messageId: 'noAssertions', type: 'Identifier', }],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL

},
{
code: 'test.skip("should fail", () => {});',
errors: [{ messageId: 'noAssertions' }],
errors: [{ messageId: 'noAssertions', type: 'MemberExpression' }],
},
{
code: javascript`
test('should fail', async ({ page }) => {
await assertCustomCondition(page)
})
`,
errors: [{ messageId: 'noAssertions' }],
errors: [{ messageId: 'noAssertions', type: 'Identifier' }],
},
{
code: javascript`
test('should fail', async ({ page }) => {
await assertCustomCondition(page)
})
`,
errors: [{ messageId: 'noAssertions' }],
errors: [{ messageId: 'noAssertions', type: 'Identifier' }],
name: 'Custom assert function',
options: [{ assertFunctionNames: ['wayComplexCustomCondition'] }],
},
{
code: 'it("should pass", () => hi(true).toBeDefined())',
errors: [{ messageId: 'noAssertions' }],
errors: [{ messageId: 'noAssertions', type: 'Identifier' }],
name: 'Global aliases',
settings: {
playwright: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/expect-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default createRule({
},
'Program:exit'() {
unchecked.forEach((node) => {
context.report({ messageId: 'noAssertions', node })
context.report({ messageId: 'noAssertions', node: node.callee })
})
},
}
Expand Down
Loading