skills/api-playwright-test-developer/SKILL.md
Writes and reviews API automation tests with Playwright Test, covering setup/teardown, assertions, data management, and hybrid API+UI flows. Use when creating backend API tests, contract checks, data-driven API coverage, API+UI hybrid workflows, or reviewing existing Playwright API suites.
npx skillsauth add jaktestowac/awesome-copilot-for-testers api-playwright-test-developerInstall 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.
This skill defines the standard approach for writing and maintaining Playwright-based API tests. It is optimized for robust, repeatable automated validation of REST/GraphQL services, readable test design, and minimal flakiness.
test.beforeEach and test.afterEach for consistent test state management (e.g., create/delete test data).test.afterEach by default. Skip cleanup only temporarily when debugging a failure, and never commit that state.test.step to logically group related API calls and assertions within a single test case.expect.soft for multiple checks in a single test without stopping at the first failure.beforeEach to create necessary resources instead of relying on static test data.request fixture for API calls.test.describe to group related tests and share setup/teardown logic..
├── tests/
│ ├── api/
│ │ ├── users.spec.ts
│ │ ├── auth.spec.ts
│ │ ├── orders.spec.ts
│ │ └── contracts.spec.ts
│ ├── e2e/
│ │ ├── signup-and-purchase.spec.ts
│ │ └── checkout-api-ui.spec.ts
│ └── fixtures/
│ ├── api-fixtures.ts
│ ├── data-fixtures.ts
│ └── auth-fixtures.ts
├── helpers/
│ ├── api-helpers.ts
│ ├── schema-validators.ts
│ └── retry-utils.ts
├── data/
│ └── payloads/
│ ├── create-user.json
│ ├── update-order.json
│ └── login.json
├── docs/
│ └── api-test-guidelines.md
├── .github/
│ └── workflows/
│ └── api-tests.yml
├── playwright.config.ts
└── .env.example
tests/api/: dedicated API service tests and contract/spec tests.tests/e2e/: hybrid scenarios that combine UI and API flows.tests/fixtures/: setup data and auth fixtures for Playwright Test.helpers/: reusable request builders, response assertions, schema validators.data/payloads/: canonical test payloads to avoid inline duplication..env.example: environment abstraction for endpoints and tokens..github/workflows/api-tests.yml: CI pipeline orchestration with separate API test job.import { test, expect } from '@playwright/test';
test.describe('API: /users', () => {
test('GET /users returns 200 and JSON schema', async ({ request }) => {
const response = await request.get('/api/users', {
headers: { Authorization: `Bearer ${process.env.API_TOKEN}` },
});
expect(response.status()).toBe(200);
expect(response.headers()['content-type']).toContain('application/json');
const body = await response.json();
expect(Array.isArray(body)).toBeTruthy();
expect(body.length).toBeGreaterThanOrEqual(0);
});
});
request.get, request.post, request.put, request.delete
HTTP retries for transient 5xx responses (in test infrastructure, not per-test)
Data-driven tests: Playwright Test has no test.each - loop over a test-case array instead, so each case registers as its own test:
const cases = [
{ name: 'admin', role: 'admin', expectedStatus: 200 },
{ name: 'guest', role: 'guest', expectedStatus: 403 },
];
for (const data of cases) {
test(`GET /reports as ${data.name} returns ${data.expectedStatus}`, async ({ request }) => {
const response = await request.get('/api/reports', {
headers: { Authorization: `Bearer ${tokenFor(data.role)}` },
});
expect(response.status()).toBe(data.expectedStatus);
});
}
See the parameterize guide: https://playwright.dev/docs/test-parameterize
Auth token refresh helpers and failures when invalid credentials are used
Validate headers cache-control, strict-transport-security, etc. for security tests
POST /auth/login → token/v1, /v2), check mock interceptstimeout in request and page.waitForResponse with precise matchertest.step for complex flows to improve readabilityafterEachdesigning-test-data - when the test data strategy needs dedicated designverifying-acceptance-criteria - when API behavior must be checked against stated acceptance criteriacode-review-advanced - when an existing API suite needs a structured reviewThis skill is complete when:
afterEachtest.eachtesting
Tests the customization assets themselves - skills, prompts, custom agents, instructions - the way a product is tested: activation cases that check an asset fires when it should and stays quiet when it should not, output-contract cases, safety cases, collision cases between assets competing for the same trigger, a weighted rubric scored blind, and a baseline-versus-candidate gate before an edit ships. Use when a skill is edited and nobody knows whether behaviour changed, when two skills fight over the same request, when a description is being tuned for discoverability, when a collection has grown past manual spot-checking, or when the request mentions skill evals, prompt regression, or "does this skill actually work".
development
Shapes QA output for the person who has to act on it: result and blocker in the first two lines, one decision per report, findings ordered by what they cost, the long artifact in a file and the decisions in the message, and magnitude stated in units the reader can count. Use when a report is accurate but nobody acts on it, when a finding set is too long to read under time pressure, when the same findings must be retold for a developer, a release manager, and an on-call engineer, or when the request mentions "too long", "make this readable", "just tell me what to do", "so what", or "summarize this for stakeholders". Pairs with unslop-answers, which makes the same report honest.
testing
Verifies that the lines and branches a change actually touched are executed by tests, using LCOV or Cobertura diff coverage instead of whole-repo percentages, and escalates uncovered high-risk changes into a blocking finding. Use when a pull request needs a coverage gate that unrelated tests cannot satisfy, when total coverage looks healthy but the diff is untested, when wiring diff coverage into CI, or when someone claims a change is covered because the suite is green.
development
Cuts AI tells from test code: tests that pass without proving anything, tautological assertions, mock-only tests, hardcoded waits, coverage theater, vague names, swallowed errors, retries used as fixes. Use whenever test code is written, changed, or reviewed, including tests produced as a side effect of a feature task, and when the request mentions "review these tests", "are these tests any good", "this test always passes", "this suite is flaky", or "clean up these tests". Must always apply to test code.