.claude/skills/playwright-testing/SKILL.md
Expert guidance for writing end-to-end tests with Playwright Test framework. Use this skill when writing browser automation tests, creating test suites, working with locators and assertions, mocking network requests, handling authentication, or configuring the Playwright test runner. Trigger keywords include "playwright", "e2e test", "end-to-end", "browser test", "getByRole", "locator", "toBeVisible", "page.goto", "test runner".
npx skillsauth add aehrc/pathling playwright-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
End-to-end testing framework with auto-waiting, web-first assertions, and multi-browser support.
import { test, expect } from "@playwright/test";
test("user can log in", async ({ page }) => {
await page.goto("/login");
await page.getByLabel("Email").fill("[email protected]");
await page.getByLabel("Password").fill("secret");
await page.getByRole("button", { name: "Sign in" }).click();
await expect(page.getByText("Welcome")).toBeVisible();
});
page.getByRole('button', { name: 'Submit' }) — ARIA roles (most resilient)page.getByLabel('Email') — Form labelspage.getByText('Welcome') — Visible textpage.getByTestId('user-menu') — Test IDs (explicit contracts)page.getByPlaceholder('Search') — Placeholder textAvoid CSS selectors and XPath—they break with DOM changes.
Chaining and filtering:
// Chain to narrow scope
page.locator(".modal").getByRole("button", { name: "Save" });
// Filter by text or child elements
page.getByRole("listitem").filter({ hasText: "Product" });
page.getByRole("listitem").filter({ has: page.getByRole("button") });
See references/locators.md for complete locator API.
Auto-retrying (use these for web elements):
await expect(locator).toBeVisible();
await expect(locator).toHaveText("Hello");
await expect(locator).toHaveValue("input text");
await expect(locator).toBeChecked();
await expect(page).toHaveURL(/dashboard/);
Non-retrying (for static values):
expect(value).toBe(5);
expect(array).toContain("item");
expect(obj).toEqual({ key: "value" });
See references/assertions.md for all assertion types.
await locator.click();
await locator.fill("text"); // Clear and type
await locator.pressSequentially("t"); // Character by character
await locator.selectOption("value");
await locator.check(); // Checkbox
await locator.setInputFiles("file.pdf");
await page.keyboard.press("Enter");
All actions auto-wait for elements to be visible, stable, and enabled.
See references/actions.md for complete action reference.
import { test, expect } from "@playwright/test";
test.describe("Feature", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/");
});
test("scenario one", async ({ page }) => {
// Arrange - Act - Assert
});
test("scenario two", async ({ page }) => {
// ...
});
});
test.beforeEach() / test.afterEach() — Run before/after each testtest.beforeAll() / test.afterAll() — Run once per workerMinimal playwright.config.ts:
import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
testDir: "./tests",
fullyParallel: true,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 2 : undefined,
reporter: "html",
use: {
baseURL: "http://localhost:3000",
trace: "on-first-retry",
},
projects: [
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
{ name: "firefox", use: { ...devices["Desktop Firefox"] } },
{ name: "webkit", use: { ...devices["Desktop Safari"] } },
],
webServer: {
command: "npm run dev",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
},
});
See references/configuration.md for all options.
npx playwright test # Run all tests
npx playwright test --ui # Interactive UI mode
npx playwright test --headed # Show browser
npx playwright test --debug # Step-through debugger
npx playwright test -g "login" # Filter by title
npx playwright test --project=chromium # Specific browser
npx playwright test --last-failed # Retry failures only
npx playwright codegen # Generate tests
npx playwright show-report # View HTML report
await page.route("**/api/users", (route) =>
route.fulfill({ json: [{ id: 1, name: "Mock User" }] }),
);
await page.route("**/api/error", (route) => route.fulfill({ status: 500 }));
// Save auth state after login
await page.context().storageState({ path: "auth.json" });
// Reuse in config
use: {
storageState: "auth.json";
}
const test = base.extend<{ userPage: Page }>({
userPage: async ({ browser }, use) => {
const context = await browser.newContext();
const page = await context.newPage();
await page.goto("/login");
// ... login
await use(page);
await context.close();
},
});
See references/advanced.md for network mocking, auth patterns, fixtures, and Page Object Model.
getByRole() is most resilient to changesawait expect(locator).toBeVisible() not locator.isVisible()expect.soft() continues after failure for comprehensive reportstools
Expert guidance for using WireMock in Java applications for HTTP API mocking and testing. Use this skill when the user asks to mock HTTP APIs, create API stubs, test REST clients, simulate network faults, verify HTTP requests, or integrate WireMock with Spring Boot. Trigger keywords include "wiremock", "mock http", "stub api", "http mock", "api testing", "rest mock", "simulate fault", "verify request", "spring boot wiremock".
documentation
Expert guidance for implementing SQL on FHIR v2 ViewDefinitions and operations to create portable, tabular projections of FHIR data. Use this skill when the user asks to create ViewDefinitions, flatten FHIR resources into tables, write FHIRPath expressions for data extraction, implement forEach/forEachOrNull/repeat patterns for unnesting, create where clauses for filtering, use constants in view definitions, combine data with unionAll, execute ViewDefinitions with $run or $export operations, or implement SQL on FHIR server capabilities. Trigger keywords include "ViewDefinition", "SQL on FHIR", "flatten FHIR", "tabular FHIR", "FHIR to SQL", "FHIR analytics", "FHIRPath columns", "unnest FHIR", "$viewdefinition-run", "$export", "view runner", "repeat", "recursive", "QuestionnaireResponse".
development
Expert guidance for working with the Apache Spark Catalyst query optimisation framework. Use this skill when working with Spark SQL internals, creating custom expressions, implementing query optimisations, working with logical/physical plans, or extending Catalyst. Trigger keywords include "catalyst", "spark sql", "expression", "logical plan", "physical plan", "tree node", "query optimisation", "rule executor", "analyzer", "optimizer", "code generation".
development
Expert guidance for using the SonarCloud API to interact with code quality analysis, projects, issues, quality gates, and metrics. Use this skill when making API calls to SonarCloud, automating code quality workflows, retrieving analysis results, managing projects programmatically, or integrating SonarCloud with CI/CD pipelines. Trigger keywords include "SonarCloud", "SonarCloud API", "code quality API", "SonarQube Cloud", "quality gate", "code analysis API", "SonarCloud measures", "SonarCloud issues".