Annotations
Four built-in annotations control how tests run: skip (don't run), fixme (known failure, don't run), fail (expect failure, do run), slow (triple the timeout). I use test.skip(condition) constantly — it's how I handle browser-specific bugs without deleting the test.
The four built-in annotations
Each one changes what Playwright does with the test in a different way.
Conditional skip — browser or environment specific
The most useful pattern I know: skip a test only on a specific browser. The bug is real, the ticket is filed, but I don't want the whole test suite to be red just because of a Safari-specific issue.
test.only — focus on one test locally
When debugging, add test.only() to run just that test. The whole file becomes focused on it. Never commit `test.only` — use forbidOnly: !!process.env.CI in config to make CI fail if you accidentally leave it in.
Annotations — link tests to issues
Annotations are metadata attached to a test — type and description. They appear in the HTML report. I use them to link tests to JIRA tickets or GitHub issues, so when a test fails I can immediately see which issue it relates to.
test.describe — group related tests
test.describe() groups tests under a shared name and scopes beforeEach/afterEach hooks to just that group. I use it when a feature has multiple related scenarios that share setup.