Sign in
Explore
Prompts · RulesTesting & SecurityReviewed

playwright-typescript

Playwright test generation instructions.

Kind
Rules
Works with
GitHub Copilot
Languages
TypeScript / JavaScript
Source
Awesome Copilot @ d85f762d6e52
Path
instructions/playwright-typescript.instructions.md
License
MIT
Jobs
Testing
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
## Test Writing Guidelines

### Code Quality Standards
- **Locators**: Prioritize user-facing, role-based locators (`getByRole`, `getByLabel`, `getByText`, etc.) for resilience and accessibility. Use `test.step()` to group interactions and improve test readability and reporting.
- **Assertions**: Use auto-retrying web-first assertions. These assertions start with the `await` keyword (e.g., `await expect(locator).toHaveText()`). Avoid `expect(locator).toBeVisible()` unless specifically testing for visibility changes.
- **Timeouts**: Rely on Playwright's built-in auto-waiting mechanisms. Avoid hard-coded waits or increased default timeouts.
- **Clarity**: Use descriptive test and step titles that clearly state the intent. Add comments only to explain complex logic or non-obvious interactions.


### Test Structure
- **Imports**: Start with `import { test, expect } from '@playwright/test';`.
- **Organization**: Group related tests for a feature under a `test.describe()` block.
- **Hooks**: Use `beforeEach` for setup actions common to all tests in a `describe` block (e.g., navigating to a page).
…