Skip to content

Feature request: check page and locator actions for missing-playwright-await rule #159

@benatshippabo

Description

@benatshippabo

Suggestion

We should add additional functions to check if they are being awaited on. Currently we only check expect and test matchers, but none of the page actions or locator actions:

const validTypes = new Set([
'AwaitExpression',
'ReturnStatement',
'ArrowFunctionExpression',
]);
const expectPlaywrightMatchers = [
'toBeChecked',
'toBeDisabled',
'toBeEnabled',
'toEqualText', // deprecated
'toEqualUrl',
'toEqualValue',
'toHaveFocus',
'toHaveSelector',
'toHaveSelectorCount',
'toHaveText', // deprecated
'toMatchAttribute',
'toMatchComputedStyle',
'toMatchText',
'toMatchTitle',
'toMatchURL',
'toMatchValue',
];
const playwrightTestMatchers = [
'toBeChecked',
'toBeDisabled',
'toBeEditable',
'toBeEmpty',
'toBeEnabled',
'toBeFocused',
'toBeHidden',
'toBeVisible',
'toContainText',
'toHaveAttribute',
'toHaveClass',
'toHaveCount',
'toHaveCSS',
'toHaveId',
'toHaveJSProperty',
'toBeOK',
'toHaveScreenshot',
'toHaveText',
'toHaveTitle',
'toHaveURL',
'toHaveValue',
];

Activity

revelt

revelt commented on Oct 12, 2023

@revelt

just to add 2p, for example, currently, this missing page await is not flagged up:

test('has title', async ({ page }) => {
  page.goto('https://playwright.dev/'); // await is missing!
// ^^^

  // Expect a title "to contain" a substring.
  await expect(page).toHaveTitle(/Playwright/);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @revelt@mskelton@benatshippabo

        Issue actions

          Feature request: check page and locator actions for `missing-playwright-await` rule · Issue #159 · playwright-community/eslint-plugin-playwright