playwright-best-practices

작성자: sanity-io

Playwright 테스트 작성, 불안정한 테스트 수정, 실패 디버깅, Page Object Model 구현, CI/CD 구성, 성능 최적화, 모킹 시 사용합니다.

npx skills add https://github.com/sanity-io/sanity --skill playwright-best-practices

Playwright Best Practices

This skill provides comprehensive guidance for all aspects of Playwright test development, from writing new tests to debugging and maintaining existing test suites.

Activity-Based Reference Guide

Consult these references based on what you're doing:

Writing New Tests

When to use: Creating new test files, writing test cases, implementing test scenarios

ActivityReference Files
Writing E2E teststest-suite-structure.md, locators.md, assertions-waiting.md
Writing component testscomponent-testing.md, test-suite-structure.md
Writing API testsapi-testing.md, test-suite-structure.md
Writing GraphQL testsgraphql-testing.md, api-testing.md
Writing visual regression testsvisual-regression.md, canvas-webgl.md
Structuring test code with POMpage-object-model.md, test-suite-structure.md
Setting up test data/fixturesfixtures-hooks.md, test-data.md
Handling authenticationauthentication.md, authentication-flows.md
Testing date/time featuresclock-mocking.md
Testing file upload/downloadfile-operations.md, file-upload-download.md
Testing forms/validationforms-validation.md
Testing drag and dropdrag-drop.md
Testing accessibilityaccessibility.md
Testing security (XSS, CSRF)security-testing.md
Using test annotationsannotations.md
Using test tagstest-tags.md
Testing iframesiframes.md
Testing canvas/WebGLcanvas-webgl.md
Internationalization (i18n)i18n.md
Testing Electron appselectron.md
Testing browser extensionsbrowser-extensions.md

Mobile & Responsive Testing

When to use: Testing mobile devices, touch interactions, responsive layouts

ActivityReference Files
Device emulationmobile-testing.md
Touch gestures (swipe, tap)mobile-testing.md
Viewport/breakpoint testingmobile-testing.md
Mobile-specific UImobile-testing.md, locators.md

Real-Time & Browser APIs

When to use: Testing WebSockets, geolocation, permissions, multi-tab flows

ActivityReference Files
WebSocket/real-time testingwebsockets.md
Geolocation mockingbrowser-apis.md
Permission handlingbrowser-apis.md
Clipboard testingbrowser-apis.md
Camera/microphone mockingbrowser-apis.md
Multi-tab/popup flowsmulti-context.md
OAuth popup handlingthird-party.md, multi-context.md

Debugging & Troubleshooting

When to use: Test failures, element not found, timeouts, unexpected behavior

ActivityReference Files
Debugging test failuresdebugging.md, assertions-waiting.md
Fixing flaky testsflaky-tests.md, debugging.md, assertions-waiting.md
Debugging flaky parallel runsflaky-tests.md, performance.md, fixtures-hooks.md
Ensuring test isolation / avoiding state leakflaky-tests.md, fixtures-hooks.md, performance.md
Fixing selector issueslocators.md, debugging.md
Investigating timeout issuesassertions-waiting.md, debugging.md
Using trace viewerdebugging.md
Debugging race conditionsflaky-tests.md, debugging.md, assertions-waiting.md
Debugging console/JS errorsconsole-errors.md, debugging.md

Error & Edge Case Testing

When to use: Testing error states, offline mode, network failures, validation

ActivityReference Files
Error boundary testingerror-testing.md
Network failure simulationerror-testing.md, network-advanced.md
Offline mode testingerror-testing.md, service-workers.md
Service worker testingservice-workers.md
Loading state testingerror-testing.md
Form validation testingerror-testing.md

Multi-User & Collaboration Testing

When to use: Testing features involving multiple users, roles, or real-time collaboration

ActivityReference Files
Multiple users in one testmulti-user.md
Real-time collaborationmulti-user.md, websockets.md
Role-based access testingmulti-user.md
Concurrent action testingmulti-user.md

Architecture Decisions

When to use: Choosing test patterns, deciding between approaches, planning test architecture

ActivityReference Files
POM vs fixtures decisionpom-vs-fixtures.md
Test type selectiontest-architecture.md
Mock vs real serviceswhen-to-mock.md
Test suite structuretest-suite-structure.md

Framework-Specific Testing

When to use: Testing React, Angular, Vue, or Next.js applications

ActivityReference Files
Testing React appsreact.md
Testing Angular appsangular.md
Testing Vue/Nuxt appsvue.md
Testing Next.js appsnextjs.md

Refactoring & Maintenance

When to use: Improving existing tests, code review, reducing duplication

ActivityReference Files
Refactoring to Page Object Modelpage-object-model.md, test-suite-structure.md
Improving test organizationtest-suite-structure.md, page-object-model.md
Extracting common setup/teardownfixtures-hooks.md
Replacing brittle selectorslocators.md
Removing explicit waitsassertions-waiting.md
Creating test data factoriestest-data.md
Configuration setupconfiguration.md

Infrastructure & Configuration

When to use: Setting up projects, configuring CI/CD, optimizing performance

ActivityReference Files
Configuring Playwright projectconfiguration.md, projects-dependencies.md
Setting up CI/CD pipelinesci-cd.md, github-actions.md
GitHub Actions setupgithub-actions.md
GitLab CI setupgitlab.md
Other CI providersother-providers.md
Docker/container setupdocker.md
Global setup & teardownglobal-setup.md
Project dependenciesprojects-dependencies.md
Optimizing test performanceperformance.md, test-suite-structure.md
Configuring parallel executionparallel-sharding.md, performance.md
Isolating test data between workersfixtures-hooks.md, performance.md
Test coveragetest-coverage.md
Test reporting/artifactsreporting.md

Advanced Patterns

When to use: Complex scenarios, API mocking, network interception

ActivityReference Files
Mocking API responsestest-suite-structure.md, network-advanced.md
Network interceptionnetwork-advanced.md, assertions-waiting.md
GraphQL mockingnetwork-advanced.md
HAR recording/playbacknetwork-advanced.md
Custom fixturesfixtures-hooks.md
Advanced waiting strategiesassertions-waiting.md
OAuth/SSO mockingthird-party.md, multi-context.md
Payment gateway mockingthird-party.md
Email/SMS verification mockingthird-party.md
Failing on console errorsconsole-errors.md
Security testing (XSS, CSRF)security-testing.md
Performance budgets & Web Vitalsperformance-testing.md
Lighthouse integrationperformance-testing.md
Test annotations (skip, fixme)annotations.md
Test tags (@smoke, @fast)test-tags.md
Test steps for reportingannotations.md

Quick Decision Tree

What are you doing?
│
├─ Writing a new test?
│  ├─ E2E test → core/test-suite-structure.md, core/locators.md, core/assertions-waiting.md
│  ├─ Component test → testing-patterns/component-testing.md
│  ├─ API test → testing-patterns/api-testing.md, core/test-suite-structure.md
│  ├─ GraphQL test → testing-patterns/graphql-testing.md
│  ├─ Visual regression → testing-patterns/visual-regression.md
│  ├─ Visual/canvas test → testing-patterns/canvas-webgl.md, core/test-suite-structure.md
│  ├─ Accessibility test → testing-patterns/accessibility.md
│  ├─ Mobile/responsive test → advanced/mobile-testing.md
│  ├─ i18n/locale test → testing-patterns/i18n.md
│  ├─ Electron app test → testing-patterns/electron.md
│  ├─ Browser extension test → testing-patterns/browser-extensions.md
│  ├─ Multi-user test → advanced/multi-user.md
│  ├─ Form validation test → testing-patterns/forms-validation.md
│  └─ Drag and drop test → testing-patterns/drag-drop.md
│
├─ Testing specific features?
│  ├─ File upload/download → testing-patterns/file-operations.md, testing-patterns/file-upload-download.md
│  ├─ Date/time dependent → advanced/clock-mocking.md
│  ├─ WebSocket/real-time → browser-apis/websockets.md
│  ├─ Geolocation/permissions → browser-apis/browser-apis.md
│  ├─ OAuth/SSO mocking → advanced/third-party.md, advanced/multi-context.md
│  ├─ Payments/email/SMS → advanced/third-party.md
│  ├─ iFrames → browser-apis/iframes.md
│  ├─ Canvas/WebGL/charts → testing-patterns/canvas-webgl.md
│  ├─ Service workers/PWA → browser-apis/service-workers.md
│  ├─ i18n/localization → testing-patterns/i18n.md
│  ├─ Security (XSS, CSRF) → testing-patterns/security-testing.md
│  └─ Performance/Web Vitals → testing-patterns/performance-testing.md
│
├─ Architecture decisions?
│  ├─ POM vs fixtures → architecture/pom-vs-fixtures.md
│  ├─ Test type selection → architecture/test-architecture.md
│  ├─ Mock vs real services → architecture/when-to-mock.md
│  └─ Test suite structure → core/test-suite-structure.md
│
├─ Framework-specific testing?
│  ├─ React app → frameworks/react.md
│  ├─ Angular app → frameworks/angular.md
│  ├─ Vue/Nuxt app → frameworks/vue.md
│  └─ Next.js app → frameworks/nextjs.md
│
├─ Authentication testing?
│  ├─ Basic auth patterns → advanced/authentication.md
│  └─ Complex flows (MFA, reset) → advanced/authentication-flows.md
│
├─ Test is failing/flaky?
│  ├─ Flaky test investigation → debugging/flaky-tests.md
│  ├─ Element not found → core/locators.md, debugging/debugging.md
│  ├─ Timeout issues → core/assertions-waiting.md, debugging/debugging.md
│  ├─ Race conditions → debugging/flaky-tests.md, debugging/debugging.md
│  ├─ Flaky only with multiple workers → debugging/flaky-tests.md, infrastructure-ci-cd/performance.md
│  ├─ State leak / isolation → debugging/flaky-tests.md, core/fixtures-hooks.md
│  ├─ Console/JS errors → debugging/console-errors.md, debugging/debugging.md
│  └─ General debugging → debugging/debugging.md
│
├─ Testing error scenarios?
│  ├─ Network failures → debugging/error-testing.md, advanced/network-advanced.md
│  ├─ Offline (unexpected) → debugging/error-testing.md
│  ├─ Offline-first/PWA → browser-apis/service-workers.md
│  ├─ Error boundaries → debugging/error-testing.md
│  └─ Form validation → testing-patterns/forms-validation.md, debugging/error-testing.md
│
├─ Refactoring existing code?
│  ├─ Implementing POM → core/page-object-model.md
│  ├─ Improving selectors → core/locators.md
│  ├─ Extracting fixtures → core/fixtures-hooks.md
│  ├─ Creating data factories → core/test-data.md
│  └─ Configuration setup → core/configuration.md
│
├─ Setting up infrastructure?
│  ├─ CI/CD → infrastructure-ci-cd/ci-cd.md
│  ├─ GitHub Actions → infrastructure-ci-cd/github-actions.md
│  ├─ GitLab CI → infrastructure-ci-cd/gitlab.md
│  ├─ Other CI providers → infrastructure-ci-cd/other-providers.md
│  ├─ Docker/containers → infrastructure-ci-cd/docker.md
│  ├─ Sharding/parallel → infrastructure-ci-cd/parallel-sharding.md
│  ├─ Reporting/artifacts → infrastructure-ci-cd/reporting.md
│  ├─ Global setup/teardown → core/global-setup.md
│  ├─ Project dependencies → core/projects-dependencies.md
│  ├─ Test performance → infrastructure-ci-cd/performance.md
│  ├─ Test coverage → infrastructure-ci-cd/test-coverage.md
│  └─ Project config → core/configuration.md, core/projects-dependencies.md
│
├─ Organizing tests?
│  ├─ Skip/fixme/slow tests → core/annotations.md
│  ├─ Test tags (@smoke, @fast) → core/test-tags.md
│  ├─ Filtering tests (--grep) → core/test-tags.md
│  ├─ Test steps → core/annotations.md
│  └─ Conditional execution → core/annotations.md
│
└─ Running subset of tests?
   ├─ By tag (@smoke, @critical) → core/test-tags.md
   ├─ Exclude slow/flaky tests → core/test-tags.md
   ├─ PR vs nightly tests → core/test-tags.md, infrastructure-ci-cd/ci-cd.md
   └─ Project-specific filtering → core/test-tags.md, core/configuration.md

Test Validation Loop

After writing or modifying tests:

  1. Run tests: npx playwright test --reporter=list
  2. If tests fail:
    • Review error output and trace (npx playwright show-trace)
    • Fix locators, waits, or assertions
    • Re-run tests
  3. Only proceed when all tests pass
  4. Run multiple times for critical tests: npx playwright test --repeat-each=5

sanity-io의 다른 스킬

sanity-migration
sanity-io
다른 CMS 및 콘텐츠 시스템에서 Sanity로의 마이그레이션을 계획, 구현 및 검토합니다. AEM, Adobe Experience Manager, Contentful, Strapi, Webflow, WordPress, Payload, Drupal, Markdown/MDX/frontmatter 파일, WXR/XML 내보내기, CMS API, 데이터베이스 덤프, 정적 HTML에서 Sanity로 마이그레이션하거나 리플랫폼할 때, 또는 추출, 변환, Portable Text 변환, 에셋 마이그레이션, 리디렉션, 검증 및 전환 워크플로를 설계할 때 사용합니다.
officialdevelopmentdatabase
create-agent-with-sanity-context
sanity-io
Agent Context를 통해 Sanity 콘텐츠에 구조화된 접근 권한을 가진 AI 에이전트를 구축합니다. Sanity 기반 챗봇을 설정하거나 AI 어시스턴트를 Sanity에 연결할 때 사용합니다…
official
dial-your-context
sanity-io
대화형 세션으로 Sanity Agent Context MCP의 Instructions 필드 콘텐츠를 생성합니다. 사용자가 에이전트 컨텍스트 튜닝, 개선 등을 언급할 때 이 스킬을 사용하세요.
official
optimize-agent-prompt
sanity-io
안내 대화를 통해 Sanity Agent Context 에이전트를 조정합니다. 탐색 데이터를 프로덕션 준비가 완료된 지침으로 변환하고 시스템 프롬프트를 제작합니다…
official
shape-your-agent
sanity-io
Sanity Agent Context MCP로 구동되는 AI 에이전트의 시스템 프롬프트를 제작하는 대화형 세션입니다. 사용자가 에이전트의 성격을 정의하려 할 때 이 스킬을 사용하세요.
official
content-experimentation-best-practices
sanity-io
콘텐츠 실험을 설계, 실행, 분석하여 전환율과 참여도를 개선하기 위한 체계적인 가이드입니다. 가설 프레임워크, 지표 선택, 표본 크기 계산, A/B 및 다변량 실험의 통계적 유의성 검정을 다룹니다. p-값, 신뢰 구간, 검정력 분석, 결과 해석을 위한 베이지안 방법에 대한 상세 자료를 포함합니다. 필드 수준에서 변형을 관리하고 외부 시스템과 연결하기 위한 CMS 통합 패턴을 제공합니다.
official
content-modeling-best-practices
sanity-io
구조화된 콘텐츠 모델링 가이드로, 스키마 설계, 재사용성, 멀티채널 전달을 다룹니다. 콘텐츠를 페이지가 아닌 데이터로 취급하고, 단일 진실 공급원을 유지하며, 미래 채널을 고려한 설계와 편집자 워크플로우 최적화를 위한 핵심 원칙을 포함합니다. 참조와 임베디드 객체 간의 결정 프레임워크, 관심사 분리, 콘텐츠 재사용 패턴을 제공하며, 플랫, 계층적, 패싯 접근 방식에 대한 분류 및 분류 체계 가이드를 포함합니다. 다음에 적용됩니다...
official
portable-text-conversion
sanity-io
HTML 및 Markdown 콘텐츠를 Sanity용 Portable Text 블록으로 변환합니다. 레거시 CMS에서 콘텐츠를 마이그레이션하거나 HTML 또는 Markdown을 Sanity로 가져올 때 사용합니다.
official