webapp-testing
Playwright E2E testing patterns for TaxHelper. Use for auth redirects, insights drill-down, mobile viewport checks, and PWA verification.
When & Why to Use This Skill
This Claude skill provides specialized Playwright E2E testing patterns designed to streamline web application quality assurance. It focuses on creating deterministic tests through API mocking, verifying complex authentication redirects, and ensuring mobile responsiveness and PWA compliance, helping developers maintain high-quality codebases with automated reliability and standardized testing conventions.
Use Cases
- Automating authentication flow testing and verifying secure redirects to sign-in pages for protected routes.
- Performing mobile viewport checks and responsive design verification to ensure UI consistency across different device sizes.
- Implementing deterministic E2E tests by mocking API routes to eliminate external database dependencies and reduce flakiness.
- Verifying Progressive Web App (PWA) functionality, including service worker registration and scope validation.
- Testing data-heavy UI components like insights and transaction lists using standardized API stubbing patterns for consistent results.
| name | webapp-testing |
|---|---|
| description | Playwright E2E testing patterns for TaxHelper. Use for auth redirects, insights drill-down, mobile viewport checks, and PWA verification. |
Webapp Testing Skill
Scope
- Use when adding or fixing Playwright E2E tests in
e2e/. - Keep tests deterministic by mocking API routes instead of hitting Prisma.
- Prefer user-visible behavior checks over implementation details.
Project Conventions
- Test location:
e2e/*.spec.ts - Runner:
npm run test:e2e - Base URL:
http://127.0.0.1:3001fromplaywright.config.ts
Auth And Fixtures
- Use
addAuthSessionfrome2e/fixtures/auth-session.tsfor authenticated tests. - Use
mockInsightsRoutesfrome2e/fixtures/insights-api.tsto stub:GET /api/insightsGET /api/transactionsGET /api/settings
- When adding new authenticated tests, ensure
/api/settingsis stubbed to avoid Prisma errors.
Common Patterns
Auth Redirect
- Navigate to a protected route (ex:
/dashboard) without auth. - Expect URL to contain
/auth/signin.
Insights Drill-Down
- Stub insights and transactions via
mockInsightsRoutes. - Use the aria label on the toggle button:
page.getByRole("button", { name: /show transactions for/i })
Mobile Viewport
- Set
test.use({ viewport: { width: 390, height: 844 } }). - Assert the nav is visible via
data-testid="mobile-nav". - Verify main padding bottom is at least the nav height.
Service Worker
- Avoid network interception flakiness.
- Assert registration scope exists:
navigator.serviceWorker.getRegistration()and checkscope.
Reliability Tips
- Use
page.context().routefor API stubs to guarantee interception. - Prefer
getByRoleandgetByTextwith stable labels. - Add
data-testidonly when no stable accessible label exists.