Skip to content

prefer-web-first-assertion fails to detect the right variable declarator #286

@An631

Description

@An631

Whenever the expect call is used with an assigned variable, the code fails to find the appropriate variable declarator in the code.

For example:

        const locatorFoo = page.locator(".foo")
        const isBarVisible = await locatorFoo.locator(".bar").isVisible()
        expect(isBarVisible).toBe(false)

In the current code we are only checking for the first VariableDeclarator in the scope of the isBarVisible variable, this means that the code grabs the locatorFoo variable and verifies if it has a call to a non-web-first assertion like isVisible().

This causes very random and incorrect behaviors in the IDE red squiggles and in the suggested automated fixes.

I have a working change with tests to fix this already if I can get PR reviews for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions