Playwright E2e Testing logo

Playwright E2e Testing

Community
fugazi
playwright-e2e-testing

Author and maintain versioned Playwright (@playwright/test) TypeScript UI specs for browser user flows. Use when asked to create, run, debug, or refactor E2E tests, form/navigation/auth flows, responsive checks, UI mocking, fixtures, Page Objects, or visual comparisons. Use api-testing for standalone REST/GraphQL contracts and playwright-cli for live browser sessions. Keywords: E2E spec, Playwright test, POM, fixtures, UI regression.

Overview

Publisherfugazi
Repositorytest-automation-skills-agents
Skill nameplaywright-e2e-testing
Stars
238
Forks
42
Bundled files
17
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 17 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by fugazi on GitHub. Read the source before you install it.

Installation

Install the Playwright E2e Testing AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fugazi/test-automation-skills-agents.git /tmp/test-automation-skills-agents
mkdir -p .claude/skills
cp -r /tmp/test-automation-skills-agents/skills/playwright-e2e-testing .claude/skills/playwright-e2e-testing
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Playwright E2e Testing in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Playwright E2e Testing on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Playwright E2e Testing is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Playwright E2E Testing (TypeScript)

Comprehensive toolkit for end-to-end testing of web applications using Playwright with TypeScript. Enables robust UI testing, UI-dependent API setup, and responsive design verification following best practices.

Activation: This skill is triggered when authoring or maintaining versioned Playwright UI specs and their test infrastructure.

When to Use This Skill

  • Write E2E tests for user flows, forms, navigation, and authentication
  • UI-dependent API setup via the request fixture or network interception
  • Responsive testing across mobile, tablet, and desktop viewports
  • Debug flaky tests using traces, screenshots, videos, and Playwright Inspector
  • Setup test infrastructure with Page Object Model and fixtures
  • Mock/intercept APIs for isolated, deterministic testing
  • Visual regression testing with screenshot comparisons

Do NOT Use For

  • Standalone API/contract testing with no browser (use api-testing).
  • Driving a live browser interactively for exploration or debugging (use playwright-cli).
  • Governing a large regression suite, tiers, or CI sharding strategy (use playwright-regression-testing).
  • Selenium/Java browser automation (use webapp-selenium-testing).

Prerequisites

RequirementDetails
Node.jsv18+ recommended
Package Managernpm, yarn, or pnpm
Playwright@playwright/test package
TypeScripttypescript + ts-node (optional but recommended)
BrowsersInstalled via npx playwright install

Quick Setup

bash
# Initialize new project
npm init playwright@latest

# Or add to existing project
npm install -D @playwright/test
npx playwright install

First Questions to Ask

Before writing tests, clarify:

  1. App URL: Local dev server command + port, or staging URL?
  2. Critical flows: Which user journeys must be covered (happy path + error states)?
  3. Browsers/devices: Chrome, Firefox, Safari? Mobile viewports?
  4. API strategy: Real backend, mocked responses, or hybrid?
  5. Test data: Seed data available? Reset/cleanup strategy?

Core Principles

1. Test Runner & TypeScript

Always use @playwright/test with TypeScript for type safety and better IDE support.

typescript
import { test, expect } from "@playwright/test";

test("user can login", async ({ page }) => {
  await page.goto("/login");
  await page.getByLabel("Email").fill("user@test.com");
  await page.getByLabel("Password").fill("password123");
  await page.getByRole("button", { name: "Sign in" }).click();
  await expect(page).toHaveURL(/.*dashboard/);
});

2. Locator Strategy (Priority Order)

Prefer role-based locators (getByRole) with accessible names, then label → placeholder → text → test ID → CSS (last resort). XPath is never used.

➡️ Full priority hierarchy, role reference, and examples: Locator Strategies: Priority — the single source of truth.

3. Auto-Waiting & Web-First Assertions

Playwright auto-waits for elements. Never use sleep() or arbitrary timeouts.

typescript
// [ok] Web-first assertions (auto-retry)
await expect(page.getByRole("alert")).toBeVisible();
await expect(page).toHaveURL(/dashboard/);
await expect(page.getByTestId("status")).toHaveText("Success!");

// [no] Avoid manual waits
await page.waitForTimeout(2000); // Bad practice

4. Test Structure with Steps

Use test.step() for readable reports and failure localization:

typescript
test("checkout flow", async ({ page }) => {
  await test.step("Add item to cart", async () => {
    await page.goto("/products/1");
    await page.getByRole("button", { name: "Add to Cart" }).click();
  });

  await test.step("Complete checkout", async () => {
    await page.goto("/checkout");
    await page.getByRole("button", { name: "Pay Now" }).click();
  });

  await test.step("Verify confirmation", async () => {
    await expect(page.getByRole("heading")).toContainText("Order Confirmed");
  });
});

Key Workflows

Forms & Navigation

typescript
// Form submit and wait for navigation (auto-waiting)
await page.getByRole("button", { name: "Login" }).click();
await expect(page).toHaveURL(/.*dashboard/);

// Form with API response validation
const responsePromise = page.waitForResponse(
  (r) => r.url().includes("/api/login") && r.status() === 200,
);
await page.getByRole("button", { name: "Login" }).click();
const response = await responsePromise;

API Testing (Request Fixture)

typescript
test("API health check", async ({ request }) => {
  const response = await request.get("/api/health");
  expect(response.ok()).toBeTruthy();
  expect(await response.json()).toMatchObject({ status: "ok" });
});

API Mocking & Interception

typescript
test("handles API error", async ({ page }) => {
  await page.route("**/api/users", (route) =>
    route.fulfill({
      status: 500,
      body: JSON.stringify({ error: "Server error" }),
    }),
  );
  await page.goto("/users");
  await expect(page.getByRole("alert")).toContainText("Something went wrong");
});

Responsive Testing

typescript
const viewports = [
  { width: 375, height: 667, name: "mobile" },
  { width: 768, height: 1024, name: "tablet" },
  { width: 1280, height: 720, name: "desktop" },
];

for (const vp of viewports) {
  test(`navigation works on ${vp.name}`, async ({ page }) => {
    await page.setViewportSize(vp);
    await page.goto("/");
    // Mobile: hamburger menu
    if (vp.width < 768) {
      await page.getByRole("button", { name: /menu/i }).click();
    }
    await page.getByRole("link", { name: "About" }).click();
    await expect(page).toHaveURL(/about/);
  });
}

Configuration

Use playwright.config.ts for project-wide settings:

typescript
import { defineConfig, devices } from "@playwright/test";

export default defineConfig({
  testDir: "./tests",
  retries: process.env.CI ? 2 : 0,
  reporter: [["html"], ["junit", { outputFile: "results.xml" }]],
  use: {
    baseURL: "http://localhost:3000",
    trace: "on-first-retry",
    screenshot: "only-on-failure",
    video: "retain-on-failure",
  },
  projects: [
    { name: "chromium", use: devices["Desktop Chrome"] },
    { name: "mobile", use: devices["Pixel 5"] },
  ],
  webServer: {
    command: "npm run dev",
    url: "http://localhost:3000",
    reuseExistingServer: !process.env.CI,
  },
});

Troubleshooting

ProblemCauseSolution
Element not foundWrong locator or not renderedUse PWDEBUG=1 to inspect, verify with getByRole
Timeout waitingElement hidden or slow loadCheck for overlays, increase timeout, use waitFor()
Flaky testsRace conditions, animationsAdd test.step(), use proper waits, disable animations
Strict mode violationMultiple elements matchUse .first(), .filter(), or more specific locator
Screenshots differDynamic contentMask dynamic areas, use deterministic data
CI fails, local passesEnvironment differencesCheck baseURL, timeouts, webServer config
API mock not workingRoute pattern mismatchUse **/api/... glob, verify with page.on('request')

CLI Quick Reference

CommandDescription
npx playwright testRun all tests headless
npx playwright test --uiOpen UI mode (interactive)
npx playwright test --headedRun with visible browser
npx playwright test --debugRun with Playwright Inspector
npx playwright test -g "login"Run tests matching pattern
npx playwright test --project=chromiumRun specific project
npx playwright show-reportOpen HTML report
npx playwright codegenGenerate tests by recording
PWDEBUG=1 npx playwright testDebug with Inspector
DEBUG=pw:api npx playwright testVerbose API logging

Red Flags

  • CSS/XPath locators when a role/label/testId is available — brittle and breaks on refactor.
  • waitForTimeout / manual sleeps instead of web-first auto-retrying assertions.
  • Tests sharing state and depending on execution order — flaky and order-coupled.
  • Assertions only on status/URL with no visible-state check — hides render regressions.
  • Inline page setup repeated across tests instead of fixtures — duplication and drift.

References

DocumentContent
Snippets: SetupConfig, auth setup, custom fixtures & logging
Snippets: InteractionsForm interactions, API testing & network interception
Snippets: Viewports & AuthResponsive viewports & authentication patterns
Snippets: Assertions & DebugAssertions, debug commands & utility helpers
Locator Strategies: PriorityLocator priority hierarchy & role-based locators
Locator Strategies: TextLabel, text, placeholder, alt-text & test-ID locators
Locator Strategies: FilteringFiltering, chaining & complex locator patterns
Locator Strategies: Anti & DebugAnti-patterns, CSS last-resort, debugging & quick reference
POM: BasicsPOM concepts, directory structure, base page & fluent API
POM: ComponentsPage object & reusable component object implementation
POM: FixturesCustom & authenticated page-object fixtures
POM: PracticesBest practices, anti-patterns & a complete worked example
Debugging: Tools & UIDebugging tools, UI mode, Inspector & headed mode
Debugging: Tracing & LogsTrace viewer, verbose logging, screenshots & videos
Debugging: Errors & NetworkConsole/page errors & network debugging
Debugging: Flaky & LocatorsFlaky-test fixes, locator debugging & quick commands

Verification

  • Uses custom fixture injection — No new PageObject() calls in spec files; all POMs injected via fixtures
  • Locators use recommended strategies — All locators use getByRole(), getByTestId(), or getByText(); no CSS selectors for interactive elements
  • Tests are independent — Each test sets up and tears down its own state; no beforeAll with shared mutable state
  • Error states covered — At least one test verifies error/empty/loading states alongside happy path

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Playwright E2e Testing AI skill do?

Author and maintain versioned Playwright (@playwright/test) TypeScript UI specs for browser user flows. Use when asked to create, run, debug, or refactor E2E tests, form/navigation/auth flows, responsive checks, UI mocking, fixtures, Page Objects, or visual comparisons. Use api-testing for standalone REST/GraphQL contracts and playwright-cli for live browser sessions. Keywords: E2E spec, Playwright test, POM, fixtures, UI regression.

Why use Playwright E2e Testing on TypingMind?

Because you install it once and use it with any model. Playwright E2e Testing is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Playwright E2e Testing in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/fugazi/test-automation-skills-agents/tree/main/skills/playwright-e2e-testing. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Playwright E2e Testing?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Playwright E2e Testing?

As many as you like. As long as a model supports skills, you can use Playwright E2e Testing with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Playwright E2e Testing AI skill free?

Yes. It is published on GitHub by fugazi under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇