Skip to content

Commit bf821f5

Browse files
committed
fix(prefer-web-first-assertions): Fix error with nested call expressions
Fixes #276
1 parent ae78045 commit bf821f5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/rules/prefer-web-first-assertions.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import dedent from 'dedent'
12
import rule from '../../src/rules/prefer-web-first-assertions'
23
import { runRuleTester, test } from '../utils/rule-tester'
34

@@ -708,6 +709,17 @@ runRuleTester('prefer-web-first-assertions', rule, {
708709
{ code: test('let visible = await foo.isVisible()') },
709710
{ code: test('const value = await bar["inputValue"]()') },
710711
{ code: test('const isEditable = await baz[`isEditable`]()') },
712+
{
713+
code: dedent`
714+
import { expect } from '@playwright/test';
715+
716+
test('my test', async ({ page }) => {
717+
await expect
718+
.poll(() => foo, { message })
719+
.toEqual(expect.objectContaining({ bar: expect.anything() }));
720+
});
721+
`,
722+
},
711723
// Global aliases
712724
{
713725
code: test('await assert(page.locator(".tweet")).toBeVisible()'),

src/rules/prefer-web-first-assertions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ const supportedMatchers = new Set([
6262
* If the expect call argument is a variable reference, finds the variable
6363
* initializer.
6464
*/
65-
function dereference(context: Rule.RuleContext, node: ESTree.Node) {
66-
if (node.type !== 'Identifier') {
65+
function dereference(context: Rule.RuleContext, node: ESTree.Node | undefined) {
66+
if (node?.type !== 'Identifier') {
6767
return node
6868
}
6969

0 commit comments

Comments
 (0)