E2e test guide
Use when writing Playwright E2E tests, integration tests, or browser-based tests. Also use when testing user flows like login, checkout, or search. Triggers on "E2E test", "Playwright test", "integration test", "end-to-end test", "browser test", or "user flow test".From its SKILL.md
npx -y skills add tyjpark0317/enterprise-os --skill e2e-test-guideAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.1 KB, as published. Nobody here has run it
Playwright E2E Test Guide
Step 1: Project Setup — verify playwright config and test accounts
Installation
# Install (if not already)
npm install -D @playwright/test # or pnpm/yarn
npx playwright install chromium
# Config: playwright.config.ts (or apps/web/playwright.config.ts in monorepos)
# Env vars loaded from .env.local automatically by config
Test Accounts
Configure test accounts for your application roles:
| Role | Notes | |
|---|---|---|
| Admin | [email protected] | Has admin permissions |
| User | [email protected] | Standard user profile |
Directory Structure
e2e/
├── auth.setup.ts # Global auth setup (cookie-based)
├── fixtures/
│ └── auth.ts # Role-specific page fixtures (adminPage, userPage)
├── pages/
│ ├── home.page.ts
│ ├── dashboard.page.ts
│ └── settings.page.ts
├── user-journey.spec.ts
├── admin-journey.spec.ts
├── edge-cases.spec.ts
└── .auth/ # Stored auth state (gitignored)
Step 2: Auth Fixtures — create cookie-based auth helpers
The auth setup creates authenticated browser contexts per role:
- Sign in via your auth provider
- Store auth state (cookies, localStorage) per role
- Provide role-specific page fixtures for tests
Never use localStorage alone for auth — server components read cookies.
Step 3: Page Objects — create page object classes
Page Object Pattern
// pages/dashboard.page.ts
import { type Page, type Locator } from '@playwright/test';
export class DashboardPage {
readonly heading: Locator;
constructor(private page: Page) {
this.heading = page.getByRole('heading', { name: 'Dashboard' });
}
async goto() {
await this.page.goto('/dashboard');
await this.page.waitForLoadState('networkidle');
}
}
Step 4: Write Tests — implement critical user journey tests
Critical User Journeys
Primary User Journey (highest priority):
- Home -> Browse items -> Apply filters
- Click item -> View details
- Take action (purchase, submit, etc.)
- Confirmation flow
- View history -> Manage items
Admin Journey:
- Dashboard -> View statistics
- Manage content -> CRUD operations
- User management -> View details
- Settings -> Configuration
Edge Cases:
- Duplicate action prevention (expect 409)
- Cancellation within policy period
- Expired session handling
- Empty state pages (no items, no history)
- Mobile viewport responsiveness
Test Template
import { test, expect } from './fixtures/auth';
import { DashboardPage } from './pages/dashboard.page';
test.describe('User Dashboard Journey', () => {
test('can view dashboard after login', async ({ userPage }) => {
const dashboard = new DashboardPage(userPage);
await dashboard.goto();
await expect(dashboard.heading).toBeVisible();
});
});
Step 5: Run and Report — execute tests and generate reports
Running Tests
# All E2E tests
npx playwright test
# Specific test file
npx playwright test e2e/user-journey.spec.ts
# With UI mode (debugging)
npx playwright test --ui
# Generate report
npx playwright show-report
Best Practices
- Use
networkidlewait for page loads - Prefer
getByRole,getByLabel,getByTextover CSS selectors - Use
axe-corefor accessibility testing (via@axe-core/playwright) - Avoid
page.waitForTimeout()— use explicit waits (waitForSelector,waitForResponse) - Set reasonable timeouts (30s default, 60s for slow operations)
- Use
test.describe.configure({ mode: 'serial' })only when tests must run in order
Checklist
- Verify project setup and config
- Configure auth fixtures (cookie-based)
- Create page objects
- Write test cases for critical user journeys
- Run tests and generate report