{"kind":"AgentDefinition","metadata":{"namespace":"community","name":"playwright-typescript","version":"0.1.0"},"spec":{"agents_md":"---\ndescription: 'Playwright test generation instructions'\napplyTo: '**'\n---\n\n## Test Writing Guidelines\n\n### Code Quality Standards\n- **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.\n- **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.\n- **Timeouts**: Rely on Playwright's built-in auto-waiting mechanisms. Avoid hard-coded waits or increased default timeouts.\n- **Clarity**: Use descriptive test and step titles that clearly state the intent. Add comments only to explain complex logic or non-obvious interactions.\n\n\n### Test Structure\n- **Imports**: Start with `import { test, expect } from '@playwright/test';`.\n- **Organization**: Group related tests for a feature under a `test.describe()` block.\n- **Hooks**: Use `beforeEach` for setup actions common to all tests in a `describe` block (e.g., navigating to a page).\n- **Titles**: Follow a clear naming convention, such as `Feature - Specific action or scenario`.\n\n\n### File Organization\n- **Location**: Store all test files in the `tests/` directory.\n- **Naming**: Use the convention `\u003cfeature-or-page\u003e.spec.ts` (e.g., `login.spec.ts`, `search.spec.ts`).\n- **Scope**: Aim for one test file per major application feature or page.\n\n### Assertion Best Practices\n- **UI Structure**: Use `toMatchAriaSnapshot` to verify the accessibility tree structure of a component. This provides a comprehensive and accessible snapshot.\n- **Element Counts**: Use `toHaveCount` to assert the number of elements found by a locator.\n- **Text Content**: Use `toHaveText` for exact text matches and `toContainText` for partial matches.\n- **Navigation**: Use `toHaveURL` to verify the page URL after an action.\n\n\n## Example Test Structure\n\n```typescript\nimport { test, expect } from '@playwright/test';\n\ntest.describe('Movie Search Feature', () =\u003e {\n  test.beforeEach(async ({ page }) =\u003e {\n    // Navigate to the application before each test\n    await page.goto('https://debs-obrien.github.io/playwright-movies-app');\n  });\n\n  test('Search for a movie by title', async ({ page }) =\u003e {\n    await test.step('Activate and perform search', async () =\u003e {\n      await page.getByRole('search').click();\n      const searchInput = page.getByRole('textbox', { name: 'Search Input' });\n      await searchInput.fill('Garfield');\n      await searchInput.press('Enter');\n    });\n\n    await test.step('Verify search results', async () =\u003e {\n      // Verify the accessibility tree of the search results\n      await expect(page.getByRole('main')).toMatchAriaSnapshot(`\n        - main:\n          - heading \"Garfield\" [level=1]\n          - heading \"search results\" [level=2]\n          - list \"movies\":\n            - listitem \"movie\":\n              - link \"poster of The Garfield Movie The Garfield Movie rating\":\n                - /url: /playwright-movies-app/movie?id=tt5779228\u0026page=1\n                - img \"poster of The Garfield Movie\"\n                - heading \"The Garfield Movie\" [level=2]\n      `);\n    });\n  });\n});\n```\n\n## Test Execution Strategy\n\n1. **Initial Run**: Execute tests with `npx playwright test --project=chromium`\n2. **Debug Failures**: Analyze test failures and identify root causes\n3. **Iterate**: Refine locators, assertions, or test logic as needed\n4. **Validate**: Ensure tests pass consistently and cover the intended functionality\n5. **Report**: Provide feedback on test results and any issues discovered\n\n## Quality Checklist\n\nBefore finalizing tests, ensure:\n- [ ] All locators are accessible and specific and avoid strict mode violations\n- [ ] Tests are grouped logically and follow a clear structure\n- [ ] Assertions are meaningful and reflect user expectations\n- [ ] Tests follow consistent naming conventions\n- [ ] Code is properly formatted and commented\n","description":"Playwright test generation instructions","import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/blob/541b7819d8c3545c6df122491af4fa1eae415779/instructions/playwright-typescript.instructions.md"},"manifest":{}},"content_hash":[108,80,152,154,76,204,113,80,125,136,212,171,168,245,162,40,41,243,209,49,254,154,9,96,75,4,49,251,117,29,51,123],"trust_level":"unsigned","yanked":false}
