name: effective-testing-methods
description: Use for implementing or amending unit tests and Playwright tests when features or behavior change, ensuring updates are validated with robust, maintainable test coverage.
Effective Testing Methods
Quick Index (Action-Routed)
Read First (All Actions)
MissionUse This Skill WhenScope BoundaryCore Principles
Action Modules (Read As Needed)
- Test planning and selection:
Test Impact MappingLayer Selection Rules
- Unit test implementation:
Unit Test PatternsUnit Test Quality Gates
- Playwright implementation:
Playwright PatternsPlaywright Stability Gates
- Validation and evidence:
Execution OrderConstrained Environment Verification PathCoverage-to-Change MapAcceptance Checklist
Output
Deliverable FormatAnti-Patterns
Mission
Ensure every feature addition or behavior change is accompanied by targeted, reliable unit and browser-level Playwright coverage.
Use This Skill When
- implementing new features or modifying existing behavior
- fixing regressions that need durable test coverage
- changing UI flows for web applications that require user-path verification
- changing business logic requiring deterministic unit test updates
Scope Boundary
This skill governs test implementation quality and test-change completeness.
Use Regression Prevention for:
- risk-tier policy and release gates
- rollback and risk acceptance decisions
Use Scripted Command Execution for:
- deterministic test command orchestration
Core Principles
- test behavior, not implementation trivia
- keep unit tests fast and deterministic
- keep Playwright tests user-centric and resilient
- map each meaningful code change to at least one validating test
- prefer small focused tests over brittle mega-tests
Test Impact Mapping
Before writing tests, map:
- changed module/route
- user-visible behavior affected
- logic branches introduced or modified
- contracts/states that can fail
- existing tests to reuse or amend
Layer Selection Rules
- always update/add unit tests for changed business logic
- add or amend Playwright for changed user flows in web apps
- include integration/contract checks when boundaries changed
- avoid using Playwright as a substitute for branch-level unit coverage
Recommended default split:
- broad unit coverage for logic edges
- targeted Playwright coverage for critical user flows
Unit Test Patterns
- arrange-act-assert structure with explicit fixtures
- one behavioral intent per test case
- table-driven tests for branch-heavy logic
- explicit edge-case and error-path tests
- no hidden dependencies on global state or test order
Unit Test Quality Gates
- deterministic outcomes across repeated runs
- no network/time randomness without explicit control
- meaningful names that describe behavior
- assertions reflect observable outcomes
- tests fail for the right reason (avoid broad catch-all assertions)
Playwright Patterns
- prefer role/text/test-id locators over brittle CSS/XPath selectors
- validate user-visible states and critical transitions
- isolate tests with clean state per test/spec where possible
- use web-first assertions and built-in auto-waiting behavior
- keep page object abstractions small and intent-focused
Playwright Stability Gates
- no fixed sleeps when reliable waits/assertions are possible
- avoid third-party dependency assertions outside your control
- capture trace/artifacts on failure for triage
- verify at least one failure-path scenario for critical flows
- keep authentication/session setup explicit and reusable
Execution Order
- run static checks and unit tests first
- run integration/contract tests next
- run targeted Playwright tests next
- run expanded Playwright matrix for high-risk changes
Constrained Environment Verification Path
Use this path when required test layers are blocked by environment constraints (for example missing browser/system libraries).
Required actions:
- record blocker evidence:
- command attempted
- exact error line
- blocked layer
- keep moving with non-blocked layers:
- static checks
- unit/integration checks (if available)
- Playwright test discovery/listing
- still update impacted tests/specs:
- ensure changed behavior is reflected in test files even if execution is blocked
- publish residual-risk classification:
medium when non-critical browser checks are blockedhigh when critical user-flow browser checks are blocked
- provide explicit rerun command for full verification when environment is fixed
Reference runbook:
skills/docs/verification/constrained-environment-verification.md
Coverage-to-Change Map
For medium/high-risk changes, provide:
- changed component/logic
- unit tests added or amended
- Playwright specs added or amended
- uncovered residual risks
Acceptance Checklist
- changed logic has updated unit coverage
- changed web user flow has updated Playwright coverage
- critical paths pass in CI/local validation
- flaky behavior is identified and mitigated
- evidence links exist for new/updated tests
- when layers are blocked, blocker evidence + rerun plan is included
When applying this skill, provide:
- change-to-test impact map
- tests added/updated by layer
- execution results summary
- residual testing risks and follow-up actions
Source Reference
Primary references:
- Playwright best practices:
- https://playwright.dev/docs/best-practices
- Google testing strategy guidance:
- https://testing.googleblog.com/2015/04/just-say-no-to-more-end-to-end-tests.html
- MIT software construction testing principles:
- https://ocw.mit.edu/courses/6-005-software-construction-spring-2016/
Anti-Patterns
- shipping behavior changes without test updates
- relying only on manual QA for changed critical paths
- brittle Playwright selectors tied to incidental DOM details
- over-mocking away the behavior under test
- asserting internals instead of outcomes