-
Notifications
You must be signed in to change notification settings - Fork 28
Docs: add a PW testing style guide #507
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
base: main
Are you sure you want to change the base?
Conversation
3. **Test IDs** (for hard to locate elements) | ||
|
||
```typescript | ||
page.locator('data-testid=submit-button'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not how you would use it - you can use 'GetByTestId`
If you are heavily interacting with your API, or writing API tests, consider using an openapi generator to generate the API client and a fixture to set up the API client for all tests that need it. | ||
|
||
## Test Structure 🏗 | ||
Recommended folder/file structure, this will make it easier to run multiple test suites and once and share helpers/fixtures if desired. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recommended folder/file structure, this will make it easier to run multiple test suites and once and share helpers/fixtures if desired. | |
Recommended folder/file structure, this will make it easier to run multiple test suites at once and share helpers/fixtures if desired. |
3. **Test IDs** (for hard to locate elements) | ||
|
||
```typescript | ||
page.locator('data-testid=submit-button'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this example, but tests ids have a few ways to get them.
This locator should be highlighted to target specific element variables.
Summary
This adds a style guide for writing Playwright tests. 💅🏼