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

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

Open
benatshippabo opened this issue Jul 21, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@benatshippabo
Copy link

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',
];

@revelt
Copy link

revelt commented Oct 12, 2023

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/);
});

@mskelton mskelton added the enhancement New feature or request label Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants