
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.
- Installs
- 1.4K
- Last 24h
- +16
- Trending rank
- #6634
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/petrkindlmann/qa-skills --skill api-testing- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads api-testing automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Discovery Questions
Check .agents/qa-project-context.md first — if it exists, use it and skip anything already answered there. Then:
- REST, GraphQL, or both? REST-only suites use standard HTTP assertions. GraphQL needs query/mutation builders and benefits from an introspection-diff snapshot.
- Auth mechanism? JWT, API key, OAuth 2.0, or session cookies — each needs a different fixture strategy.
- OpenAPI/Swagger spec available? If yes, auto-generate Zod schemas as contracts (
orval,openapi-zod-client) and consider spec-driven fuzzing with Schemathesis.
Core Principles
- Test contracts, not implementations. Assert on response shape, status codes, and headers — not on internal logic or database state.
- Schema validation catches drift before it breaks consumers. A failing schema test means you caught a breaking change before your frontend did.
- Auth flows are tests too. Test the application's login, logout, expiry and permission contracts. Exercise refresh only when supported. A cleared client cookie does not prove the server revoked the session.
- Response time is a testable assertion. Performance regressions caught in CI are cheaper than production incidents.
Exploratory vs Automated: Tooling
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.
Playwright API Testing
APIRequestContext supports standalone API tests without launching a browser and shares cookie/storage state with browser contexts. Use it for:
- Standalone API tests —
request.get/post/...with status, header, and body assertions. - Combined browser + API tests — seed data via API, assert it appears in the UI, then clean up via API.
- Authenticated fixtures — log in once in a fixture, hand a pre-authenticated
APIRequestContextto 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.
Schema Validation
Validate response shape against a schema rather than spot-checking individual fields with toHaveProperty. Two common approaches:
- Zod 4 — define a schema,
safeParsethe response, and assertresult.success. Logresult.error.issueson failure for a precise diff. Use the Zod 4 native string formats:z.email(),z.uuid(),z.iso.datetime()— the chainedz.string().email()forms are deprecated and slated for removal. - AJV with JSON Schema — when you already have JSON Schema (e.g. from an OpenAPI spec), compile and validate with
ajv+ajv-formats. - Neither installed, and the task forbids new dependencies — check the shape by hand rather than skip it: assert the exact key set (
expect(Object.keys(body).sort()).toEqual([...])) and the type of every field, in one helper reused by every test. That still fails on an added, missing or retyped field. Say in the report that a schema library was unavailable.
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.
Test Patterns
Cover each endpoint with a happy-path test plus at least one error-path test. The common patterns:
- CRUD lifecycle — a
describe.serialblock that creates, reads, updates, deletes, then verifies the 404. Carries the resource id across steps. - Auth flows — login success, invalid credentials, expiry, logout/revocation and permission boundaries. Assert the documented status and body: a resource may deliberately return indistinguishable 404s for foreign and unknown IDs. Test token refresh when the application implements it.
- Error responses — 400 (malformed body), 422 (validation with field details), 429 (rate limit +
retry-after). Don't ship happy-path-only suites. - Response headers — assert
content-type,cache-control, and rate-limit headers directly (not behind a conditional that may never fire). See the pattern below. - Pagination — first-page metadata, out-of-bounds empty page, and rejection of invalid page size.
- File upload/download — multipart upload and
content-dispositionheader verification. - GraphQL — a small
gqlhelper, then query / mutation / invalid-query (errors array) cases, plus an introspection-diff snapshot to catch silently-removed fields. - Webhooks — spin up a throwaway HTTP server, register a webhook, trigger the event, and assert delivery.
See references/test-patterns.md for the full runnable implementations of every pattern above plus performance assertions.
Response Headers
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.
test('GET /api/users sets expected response headers', async ({ request }) => {
const response = await request.get('/api/users');
const headers = response.headers();
expect(headers).toBeDefined();
expect(headers['content-type']).toContain('application/json');
expect(headers['cache-control']).toBeDefined(); // "no-store" | "max-age=60" | ...
});
For the rate-limit and retry-after variants, see references/test-patterns.md (Response Header Validation).
Performance Assertions
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.
Workflow Evidence
An HTTP success or a final happy state can miss an incorrect intermediate transition. Choose observations that distinguish the promised effect from a plausible broken one:
- Revocation: capture a valid session before logout, log out through the normal client, then replay the old credential from an independent context. Assert the protected request is denied. Keep captured credentials out of reports and source control.
- Persistence: read or restart immediately after the operation being tested, before a later write can save its state on its behalf. Check rollback before retry, and successful recovery afterward. Use real application/database state with explicit test support when needed.
- Calculated values: use independently known unit values and more than one composition. One correct aggregate can hide two compensating mistakes. Test accepted boundary values as well as values outside the allowed range.
- Raw-body signatures: sign the exact bytes sent. Include a valid noncanonical JSON representation, such as extra whitespace, plus a byte-tampered rejection case. Parsing and reserializing before verification must not silently redefine the signed message.
- Idempotency: assert one durable business effect after concurrent duplicates and after restart. Check a changed payload with the same key. Idempotent state does not require the same status on every request; repeated DELETE may return 204 then 404 if that is the contract.
Keep a healthy control and a deliberately broken control for each critical assertion when evaluating test quality. Report a missed control as a coverage gap, not a product failure.
Anti-Patterns
1. Hardcoded auth tokens
Tokens expire, rotate, and differ across environments. Use a login fixture that acquires tokens dynamically.
2. Testing against production
API tests create, modify, and delete data. Run against a dedicated test environment or local instance.
3. Not validating error responses
Happy-path-only suites miss rejection behavior. Exercise each endpoint's documented error paths and assert no forbidden side effect; do not require every HTTP status from every endpoint.
4. Asserting headers only conditionally
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.
5. No cleanup after test data creation
Tests that create resources without deleting them pollute the database. Use afterEach/afterAll hooks or fixture teardown.
6. Treating API tests as unit tests
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).
7. Ignoring idempotency
PUT and DELETE should preserve the intended state when repeated. Check state and side effects, using the endpoint's documented response contract for each attempt.
Done When
- Every target endpoint has at least a happy-path test and at least one error-path test (4xx or 5xx response validated).
- Every clause the API contract states has a test or an explicit "not covered" line in the report, including the ones no loaded skill is about: access rules on admin, debug and test-only routes, stated latency budgets, and health endpoints. A suite shaped by the skills you loaded otherwise skips the clauses between them.
- Supported auth flows exercised: successful login, invalid credentials, expiry, logout/revocation and the documented permission boundary; include refresh when implemented.
- Schema validation assertions on response shape using Zod 4 or AJV (or, where neither may be installed, an exact key-set and field-type check) — not just
toHavePropertyspot-checks. - Header assertions exist for at least
content-typeand any cache/rate-limit headers the API sets, asserted unconditionally. - Contract tests in place for any endpoint consumed by a different team or service (shared schema file; for consumer-driven verification use
contract-testing). - Genuine third-party calls (payment gateways, external SaaS) are mocked or virtualized; the API and its database run for real.
- CI job for the suite exits 0 (green) against the test environment.
Reference Files (in references/)
- playwright-setup.md —
playwright.config.ts, standalone API tests, combined browser+API tests, and the authenticatedAPIRequestContextfixture. - schema-validation.md — Zod 4 and AJV/JSON-Schema response validation, the schema-as-contract pattern, and Schemathesis spec-driven fuzzing.
- test-patterns.md — Runnable CRUD lifecycle, auth flows, error responses, response headers, pagination, file upload/download, GraphQL (+ introspection diff), webhook, and performance tests.
Related Skills
- contract-testing — Consumer-driven contract verification with Pact/broker; go there when a separate team consumes your API and you need guaranteed compatibility, not just a shared schema.
- playwright-automation — Browser-based E2E testing, Page Object Model, and combined browser + API patterns.
- ci-cd-integration — Running API test suites in CI pipelines, parallelization, and environment management.
- test-strategy — Deciding what to test at the API layer vs. unit vs. E2E.
FAQ
What does the api-testing skill do?
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.
How do I install api-testing?
Run npx skills add https://github.com/petrkindlmann/qa-skills --skill api-testing in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/api-testing/ (personal) or .claude/skills/api-testing/ (project).
Which AI agents can use api-testing?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is api-testing safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains api-testing?
It is published by petrkindlmann in petrkindlmann/qa-skills. It has 1,356 recorded installs.
More from petrkindlmann/qa-skills
playwright-automation
petrkindlmann/qa-skills
Write production-grade Playwright tests in TypeScript: Page Object Model, fixtures, auto-waiting, user-facing locators, parallel execution, CI integration, sharding, and installed-version checks. Includes an explicit "do not" list for AI agents. Use when: "Playwright," "write E2E test," "page object," "new Playwright suite," "Playwright config." Not for: fixing one flaky test at runtime — use test-reliability. Not for: bulk regenerating selectors after a UI refactor — use selector-drift-recovery. Not for: visual baseline creation/management — use visual-testing. Not for: deep WCAG/axe audits — use accessibility-testing. Related: visual-testing, ci-cd-integration, api-testing, test-reliability, selector-drift-recovery, accessibility-testing.
exploratory-testing
petrkindlmann/qa-skills
Design and execute structured exploratory testing sessions. Covers Session-Based Test Management (SBTM), charter writing, heuristic-based exploration (HICCUPS, FEW HICCUPS), bug discovery patterns, note-taking templates, and conversion of findings to automated tests. Use when: "exploratory testing," "SBTM," "manual testing," "bug hunting," "test charter," "heuristic testing." Not for: an AI browser agent autonomously exploring the app from a natural-language goal — use agentic-browser-testing. Not for: testing your product's own AI/LLM features — use ai-system-testing. Related: test-planning, ai-bug-triage, risk-based-testing, agentic-browser-testing.
test-strategy
petrkindlmann/qa-skills
Produce a multi-quarter QA strategy document. Covers scope, risk-based prioritization, test levels (unit/integration/E2E), pyramid analysis, entry/exit criteria, quality KPIs, tool selection rationale, CI scaling levers, and timeline planning. Output is an actionable strategy document, not a shelf document. Use when: "test strategy," "QA strategy doc," "testing approach," "QA roadmap," "multi-quarter QA direction." Not for: a single-sprint or single-release plan — use test-planning. Not for: identifying which areas carry the most risk — use risk-based-testing first. Related: risk-based-testing, qa-metrics, release-readiness, test-planning, test-reliability.
test-planning
petrkindlmann/qa-skills
Build a single sprint or release test plan. Covers feature decomposition into testable scenarios, requirements-to-test coverage mapping, effort estimation by test type, prioritization matrices (risk × effort), resource allocation, and scheduling with buffers. Use when: "sprint test plan," "release test plan," "what to test this sprint," "test estimation," "coverage mapping." Not for: multi-quarter strategy — use test-strategy. Not for: ranking areas by risk — use risk-based-testing. Not for: the go/no-go decision itself — use release-readiness. Related: test-strategy, risk-based-testing, release-readiness.
qa-project-context
petrkindlmann/qa-skills
Create and fill .agents/qa-project-context.md with the project's tech stack, test frameworks, CI/CD pipeline, environments, quality goals, risk areas, team structure, and conventions. This is the one file every other QA skill reads first, so they skip redundant discovery and give context-aware advice. Use when: "set up QA context," "configure testing," "initialize project," first use of any QA skill. Not for: bootstrapping a brand-new project's QA end-to-end — use qa-start (which calls this skill as its first step). Related: qa-start, risk-based-testing, test-strategy, qa-metrics, playwright-automation.
risk-based-testing
petrkindlmann/qa-skills
Produce a risk matrix or heatmap that quantifies what could break by business impact × probability, runs failure mode analysis on the top items, and maps test coverage to risk zones. Includes stakeholder interview frameworks and continuous reassessment. Run this BEFORE test-strategy or test-planning. Use when: "risk assessment," "risk matrix," "risk heatmap," "what could break," "critical paths," "failure modes," "where to focus testing." Not for: multi-quarter QA direction — use test-strategy. Not for: a single sprint/release test plan — use test-planning. Not for: hands-on session-based bug hunting — use exploratory-testing. Related: test-strategy, test-planning, release-readiness, qa-metrics.
Popular testing & qa skills
tdd
mattpocock/skills
Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
grilling
mattpocock/skills
Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
migrate-to-shoehorn
mattpocock/skills
Migrate test files from as type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace as in tests, or needs partial test data.
run-train
lllllllama/rigorpilot-skills
Rigor Train skill for deep learning research repositories. Use when a documented or selected training command should be run conservatively for startup verification, short-run verification, full kickoff, or resume, with command, config, seed, log, checkpoint, status, and metric evidence written to standardized trainoutputs/. Do not use for environment setup, exploratory sweeps, speculative idea implementation, or end-to-end orchestration.
test-driven-development
obra/superpowers
Use when implementing any feature or bugfix, before writing implementation code
finishing-a-development-branch
obra/superpowers
Use when implementation is complete, all tests pass, and you need to decide how to integrate the work