Skip to content

Missing playwright expect rule #4

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

Merged
merged 12 commits into from
Apr 28, 2021
Merged

Missing playwright expect rule #4

merged 12 commits into from
Apr 28, 2021

Conversation

mskelton
Copy link
Member

My team has found that it can be easy to forget to await async playwright matchers such as toHaveSelector, which can result in false positives since the test needs to wait for the expectation to work properly. This improves the ESLint plugin to include a new rule that will detect and auto fix this problems. For example, with this input:

expect(page).toHaveSelector('.form')

Auto fixed output:

await expect(page).toHaveSelector('.form')

Copy link
Collaborator

@mxschmitt mxschmitt left a comment

Choose a reason for hiding this comment

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

that's awesome! Seems to be similar to https://eslint.org/docs/rules/require-await

@mskelton
Copy link
Member Author

@mxschmitt I setup the GH action, and tested it on my fork. You can see the results here: https://github.com/mskelton/eslint-plugin-jest-playwright/actions/runs/794056637

Copy link
Collaborator

@mxschmitt mxschmitt left a comment

Choose a reason for hiding this comment

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

Awesome work!

@mxschmitt mxschmitt merged commit 02a5062 into playwright-community:master Apr 28, 2021
@mskelton mskelton deleted the missing-playwright-expect-rule branch April 28, 2021 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants