Back to Sanity

Playwright Best Practices Skill

.agents/skills/playwright-best-practices/README.md

5.24.09.9 KB
Original Source

░█▀█░█░░░█▀█░█░█░█░█░█▀▄░▀█▀░█▀▀░█░█░▀█▀░░░█▀▄░█▀▀░█▀▀░▀█▀░░░█▀█░█▀▄░█▀█░█▀▀░▀█▀░▀█▀░█▀▀░█▀▀░█▀▀░
░█▀▀░█░░░█▀█░░█░░█▄█░█▀▄░░█░░█░█░█▀█░░█░░░░█▀▄░█▀▀░▀▀█░░█░░░░█▀▀░█▀▄░█▀█░█░░░░█░░░█░░█░░░█▀▀░▀▀█░
░▀░░░▀▀▀░▀░▀░░▀░░▀░▀░▀░▀░▀▀▀░▀▀▀░▀░▀░░▀░░░░▀▀░░▀▀▀░▀▀▀░░▀░░░░▀░░░▀░▀░▀░▀░▀▀▀░░▀░░▀▀▀░▀▀▀░▀▀▀░▀▀▀░

by currents.dev - The all-in-one Dashboard for Playwright Testing.

Playwright Best Practices Skill

A skill that gives the AI specialized guidance for writing, debugging, and maintaining Playwright tests in TypeScript. Use it in any repo where you work with Playwright so the assistant follows best practices for E2E, component, API, visual regression, accessibility, security, i18n, Electron, and browser extension testing.

Installation

bash
npx skills add https://github.com/currents-dev/playwright-best-practices-skill

The skill is activity-based: the AI is directed to the right reference depending on what you're doing, so you get focused advice without loading everything at once.

When the Skill Is Used

The skill triggers when the AI infers you need help with things like:

  • Writing new E2E, component, API, visual regression, or accessibility tests
  • Testing mobile/responsive layouts, touch gestures, or device emulation
  • Implementing file uploads/downloads, date/time mocking, or WebSocket testing
  • Handling OAuth popups, geolocation, permissions, or multi-tab flows
  • Testing iframes, canvas/WebGL, service workers, or PWA features
  • Testing Electron desktop apps or browser extensions
  • Internationalization (i18n), locales, RTL layouts, or date/number formats
  • Testing error states, offline mode, or network failure scenarios
  • Security testing (XSS, CSRF, authentication, authorization)
  • Performance testing with Web Vitals or Lighthouse
  • Reviewing or refactoring Playwright test code
  • Fixing flaky tests or debugging failures
  • Setting up CI/CD, test coverage, or global setup/teardown
  • Configuring projects, dependencies, parallel runs, or sharding

You don't have to mention "skill" or "Playwright best practices"; describe your task (e.g. "fix this flaky login test" or "add accessibility tests") and the AI will use the skill when it's relevant.

What's Inside

57 reference documents organized into 8 categories:

Core (core/)

TopicReferenceUse for
Test structuretest-suite-structure.mdStructure, config, E2E/component/API/visual tests
Locatorslocators.mdSelectors, robustness, avoiding brittle locators
Assertions & waitingassertions-waiting.mdExpect APIs, auto-waiting, polling
Page Object Modelpage-object-model.mdPOM structure and patterns
Fixtures & hooksfixtures-hooks.mdSetup, teardown, auth, custom fixtures
Test datatest-data.mdFactories, Faker, data-driven testing
Annotationsannotations.mdskip, fixme, slow, test steps
Configurationconfiguration.mdplaywright.config.ts options
Global setupglobal-setup.mdglobalSetup/Teardown, DB migrations
Projectsprojects-dependencies.mdProject config, dependencies, filtering

Debugging (debugging/)

TopicReferenceUse for
Debuggingdebugging.mdTrace viewer, inspector, common issues
Flaky testsflaky-tests.mdDetection, diagnosis, fixing, quarantine
Error testingerror-testing.mdError boundaries, offline, network failures
Console errorsconsole-errors.mdCapturing and failing on JS errors

Testing Patterns (testing-patterns/)

TopicReferenceUse for
Accessibilityaccessibility.mdAxe-core, keyboard nav, ARIA, focus management
API testingapi-testing.mdREST API testing, request context
Component testingcomponent-testing.mdCT setup, mounting, props, mocking
Visual regressionvisual-regression.mdScreenshot comparison, thresholds
File operationsfile-operations.mdUpload, download basics
File upload/downloadfile-upload-download.mdProgress, cancellation, retry patterns
Forms validationforms-validation.mdForm testing, validation states
Drag and dropdrag-drop.mdDrag-and-drop interactions
GraphQL testinggraphql-testing.mdGraphQL queries, mutations, mocking
Canvas/WebGLcanvas-webgl.mdCanvas testing, charts, WebGL, games
i18ni18n.mdLocales, RTL, date/number formats
Electronelectron.mdDesktop apps, IPC, main/renderer process
Browser extensionsbrowser-extensions.mdPopup, background, content scripts, APIs
Security testingsecurity-testing.mdXSS, CSRF, auth security, authorization
Performance testingperformance-testing.mdWeb Vitals, budgets, Lighthouse

Advanced (advanced/)

TopicReferenceUse for
Authenticationauthentication.mdLogin flows, session storage, cookies
Auth flowsauthentication-flows.mdMFA, password reset, complex auth
Mobile testingmobile-testing.mdDevice emulation, touch gestures, viewports
Clock mockingclock-mocking.mdDate/time mocking, timezones, timers
Multi-contextmulti-context.mdPopups, new tabs, OAuth flows
Multi-usermulti-user.mdCollaboration, RBAC, concurrent actions
Network advancednetwork-advanced.mdGraphQL, HAR, request modification
Third-partythird-party.mdOAuth, payments, email/SMS mocking

Browser APIs (browser-apis/)

TopicReferenceUse for
Browser APIsbrowser-apis.mdGeolocation, permissions, clipboard, camera
WebSocketswebsockets.mdReal-time testing, SSE, reconnection
iFramesiframes.mdCross-origin, nested, dynamic iframes
Service workersservice-workers.mdPWA, caching, offline, push notifications

Architecture (architecture/)

TopicReferenceUse for
POM vs fixturespom-vs-fixtures.mdChoosing between patterns
Test architecturetest-architecture.mdTest type selection, structure
When to mockwhen-to-mock.mdMock vs real services decisions

Frameworks (frameworks/)

TopicReferenceUse for
Reactreact.mdReact-specific testing patterns
Angularangular.mdAngular-specific testing
Vuevue.mdVue/Nuxt testing patterns
Next.jsnextjs.mdNext.js SSR/SSG testing

Infrastructure & CI/CD (infrastructure-ci-cd/)

TopicReferenceUse for
CI/CDci-cd.mdPipelines, general CI setup
GitHub Actionsgithub-actions.mdGitHub-specific workflows
GitLab CIgitlab.mdGitLab-specific pipelines
Other providersother-providers.mdCircleCI, Azure DevOps, Jenkins
Dockerdocker.mdContainer setup, Playwright images
Parallel/shardingparallel-sharding.mdSharding, parallel execution
Performanceperformance.mdParallel runs, optimization
Reportingreporting.mdTest reporters, artifacts
Test coveragetest-coverage.mdV8 coverage, reports, thresholds, CI

The skill's SKILL.md maps your current activity to these references so the right content is used in context.

License

MIT