npx skills add ...
npx skills add petrkindlmann/qa-skills --skill api-testing
Test REST and GraphQL APIs with Playwright APIRequestContext, Supertest, or standalone HTTP clients. Covers schema validation with Zod 4/AJV, auth flow testing, CRUD lifecycle tests, error and header validation, pagination, and performance assertions. Use when: "API test," "endpoint test," "REST test," "GraphQL test," "schema validation," "Postman replacement." Not for: consumer-driven contract verification (Pact, broker) — use contract-testing; browser UI flows — use playwright-automation. Related: contract-testing, test-data-management, ci-cd-integration, playwright-automation.
npx skills add petrkindlmann/qa-skills --skill api-testing
Check .agents/qa-project-context.md first — if it exists, use it and skip anything already answered there. Then:
orval, openapi-zod-client) and consider spec-driven fuzzing with Schemathesis.API exploration (debugging, manual probing, OpenAPI playground) and automated API testing are different jobs. Use the right tool for each:
| Tool | Best for | Why |
|---|---|---|
| Bruno (v3.4+) | File-based collections, git-reviewable workflows, FOSS Postman replacement | Filesystem-first, no cloud sync required; gRPC + OAuth + GraphQL query builder |
| Hurl (8.x) | Plain-text HTTP testing, CI smoke checks | One file = many requests + assertions; runs anywhere curl runs; certificate + JSONPath (RFC 9535) queries |
| Hoppscotch | Web-based Postman-style exploration | Open source, runs in browser, good for quick checks |
Playwright APIRequestContext | Automated tests in your test runner | This skill's focus — covered below |
| Supertest (Node) / httpx (Python) | In-process API tests against your own app | Fastest feedback when you control both sides |
Skip Postman/Insomnia for new projects unless your team already has investment there — file-based tools (Bruno, Hurl) are easier to review in PRs and survive when collections drift.
APIRequestContext supports standalone API tests without launching a browser and shares cookie/storage state with browser contexts. Use it for:
request.get/post/... with status, header, and body assertions.APIRequestContext to tests, and dispose it on teardown. Never hardcode tokens.See references/playwright-setup.md for the playwright.config.ts, standalone tests, combined browser+API test, and the authenticated API fixture.
Validate response shape against a schema rather than spot-checking individual fields with toHaveProperty. Two common approaches:
safeParse the response, and assert result.success. Log result.error.issues on failure for a precise diff. Use the Zod 4 native string formats: z.email(), z.uuid(), z.iso.datetime() — the chained z.string().email() forms are deprecated and slated for removal.ajv + ajv-formats.Schema-as-contract: have both the API and the tests import the same schema file. If the response shape changes, consumer tests fail immediately. With an OpenAPI spec, auto-generate the schema (orval or openapi-zod-client). For spec-first teams, add Schemathesis as a CI job to fuzz the live API against the spec and catch undocumented shapes and edge-case 500s.
See references/schema-validation.md for the Zod 4, AJV, schema-as-contract, and Schemathesis implementations.
Cover each endpoint with a happy-path test plus at least one error-path test. The common patterns:
describe.serial block that creates, reads, updates, deletes, then verifies the 404. Carries the resource id across steps.retry-after). Don't ship happy-path-only suites.content-type, cache-control, and rate-limit headers directly (not behind a conditional that may never fire). See the pattern below.content-disposition header verification.gql helper, then query / mutation / invalid-query (errors array) cases, plus an introspection-diff snapshot to catch silently-removed fields.See references/test-patterns.md for the full runnable implementations of every pattern above plus performance assertions.
Headers carry the contract: cache directives, rate-limit info, content type, CORS policy. Assert them with response.headers() and index by lowercase name; don't gate the assertion behind an if (rateLimited) that may not fire.
For the rate-limit and retry-after variants, see references/test-patterns.md (Response Header Validation).
Response time and payload size are testable assertions — assert that a hot endpoint responds within a budget (e.g. 500ms), that payloads stay under a size ceiling, and that the API survives a burst of concurrent requests without 5xx. See references/test-patterns.md (Performance Assertions section) for the code.
Tokens expire, rotate, and differ across environments. Use a login fixture that acquires tokens dynamically.
API tests create, modify, and delete data. Run against a dedicated test environment or local instance.
Happy-path-only suites miss the most common production issues. Test 400, 401, 403, 404, and 500 responses for every endpoint.
Headers carry cache directives, rate limit info, content type, and CORS policy. Assert them directly on every relevant response — a check buried inside if (rateLimited) may never run and proves nothing.
Tests that create resources without deleting them pollute the database. Use afterEach/afterAll hooks or fixture teardown.
Don't mock the database — API tests verify the contract from the consumer's perspective. Mock only genuine third parties you don't own (payment gateways, external SaaS).
PUT and DELETE should be idempotent. Test that calling them twice produces the same result.
toHaveProperty spot-checks.content-type and any cache/rate-limit headers the API sets, asserted unconditionally.contract-testing).references/)playwright.config.ts, standalone API tests, combined browser+API tests, and the authenticated APIRequestContext fixture.