Skip to content

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dominikvagner
Copy link
Contributor

Summary

This adds a style guide for writing Playwright tests. 💅🏼

3. **Test IDs** (for hard to locate elements)

```typescript
page.locator('data-testid=submit-button');
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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');
Copy link
Member

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.

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.

4 participants