Adding E2E Tests
Set up Playwright end-to-end testing in a project, including test configuration, example tests, a…
by spencerpauly · CC0-1.0
The skill
Set up Playwright end-to-end testing in a project, including test configuration, example tests, and CI integration.
Add E2E Tests (Playwright)
Use this skill when the user asks to add end-to-end tests, browser tests, integration tests, or set up Playwright.
Steps
-
Install Playwright
npm init playwright@latestThis creates
playwright.config.ts, atests/directory, and installs browsers. If the project already has a test runner, install manually:npm install -D @playwright/test npx playwright install -
Configure
playwright.config.ts-
Set
baseURLto the local dev server URL (e.g.http://localhost:3000). -
Configure
webServerto start the dev server automatically:webServer: { command: "npm run dev", url: "http://localhost:3000", reuseExistingServer: !process.env.CI, }, -
Enable only chromium for local dev speed; enable all browsers in CI.
-
-
Create a smoke test — write a basic test that verifies the app loads:
import { test, expect } from "@playwright/test"; test("homepage loads", async ({ page }) => { await page.goto("/"); await expect(page).toHaveTitle(/.+/); }); -
Add page object pattern (optional) — for larger apps, create a
tests/pages/directory with page objects that encapsulate selectors and actions. -
Add npm scripts
{ "test:e2e": "playwright test", "test:e2e:ui": "playwright test --ui" } -
Add to
.gitignoretest-results/ playwright-report/ blob-report/ -
CI integration — add a GitHub Actions step that runs
npx playwright install --with-depsthennpm run test:e2e. Use the officialactions/upload-artifactto save the HTML report on failure.
Notes
- Use
data-testidattributes for selectors instead of CSS classes. - Use
test.describeto group related tests. - Run
npx playwright codegento record tests interactively.
Use this skill
Connect your agent to the Skill Store MCP server and ask for it by ref: spencerpauly/adding-e2e-tests-6936261192.
Details
- Publisher
- spencerpauly
- Category
- Software Development › Testing & QA
- License
- CC0-1.0
- Updated
- 2026-08-01
References
More from spencerpauly
- Accessibility Auditing Use Cursor's browser aria snapshots to audit a page for accessibility issues — missing labels, br…
- Adding Analytics Add PostHog analytics to a web application, including event tracking, page views, feature flags,…
- Adding Api Docs Generate OpenAPI/Swagger documentation for an API, including endpoint schemas, request/response t…
- Adding Auth Add authentication to a web application using NextAuth.js (Auth.js), including OAuth providers, s…