agentleFS
sayurionishisayurionishi/playwright-scaffold/.claude/skills/api-testing/SKILL.md

api-testing

Skill1 starsChanged 3 months agoMITView on GitHub

Use when adding API tests where the backend is the system under test — endpoint coverage, status matrix, schema validation. Phase 1 gates whether Playwright is even the right tool.

  • Reads credentials

18 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use analytics-tracking-testing, database-testing and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • petrkindlmannSkill

    analytics-tracking-testing

    Validate that analytics and marketing tracking fire CORRECTLY: GA4/GTM dataLayer events, Meta/TikTok/LinkedIn pixels, and ad-tech tags. Covers building a tracking plan as the contract, intercepting collect-endpoint beacons and dataLayer.push in Playwright, asserting event name + params + values + timing + de-duplication, Consent Mode v2 gating, CI regression gating, and news-media events (article-view, scroll-depth, paywall). Use when: "test analytics tracking," "GA4 event test," "verify the pixel fires," "dataLayer test," "tracking plan," "Meta Pixel dedup," "scroll-depth tracking test," "gate tracking in CI." Not for: whether tracking is ALLOWED to fire under consent law (GDPR/CMP) — that is compliance-testing; this skill checks the data is CORRECT. SEO meta tags / structured data — out of scope. Related: compliance-testing, playwright-automation, api-testing, qa-project-context.

    Also in 3 projects that use this

  • petrkindlmannSkill

    database-testing

    Validate database integrity, test migrations forward and backward, verify schema constraints, manage seed data, detect migration drift, and identify query performance issues. Covers PostgreSQL, MySQL, MongoDB with Prisma, TypeORM, Drizzle, and SQLAlchemy, plus Testcontainers test databases. Use when: "database test," "migration test," "migration rollback," "rollback test," "data integrity," "SQL test," "schema validation," "seed data," "query performance," "Testcontainers." Not for: synthetic data generation/masking at scale — use test-data-management; Docker/IaC test-environment provisioning — use test-environments; SQL injection — use security-testing. Related: test-data-management, test-environments, security-testing, ci-cd-integration.

    Also in 4 projects that use this

  • testified-ossSkill

    exploratory-testing

    Guide exploratory testing sessions including charter creation, session-based testing, heuristics application, and finding documentation. Use when planning exploratory testing, conducting test sessions, or documenting discoveries.

    Also in 5 projects that use this

  • conorluddySkill

    accessibility-testing

    WCAG compliance testing and accessibility quality assurance workflows for iOS apps. Use when validating accessibility labels, testing VoiceOver compatibility, checking contrast ratios, or ensuring WCAG 2.1 compliance. Covers accessibility tree analysis, semantic validation, and automated accessibility testing patterns.

    Also in 4 projects that use this

  • etewiahSkill

    e2e-testing

    Playwright E2E testing and Lighthouse performance auditing. Use when setting up E2E tests, running Playwright tests, performing Lighthouse audits, or debugging E2E test failures.

    Also in 4 projects that use this

  • MicrosoftSkill

    api-design

    Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

    Also in 4 projects that use this

  • +4 more from petrkindlmann

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 14 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Not just "empty body → 400".

    line 58
  2. Very specific:

    Write the test as the spec says, test.skip it with // FIXME: <ticket-url>.

    line 63

“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

API Testing (backend = system under test)

Runs in the api Playwright project (no browser). Tests use the api fixture (ApiRequest) and validate every response against a Zod schema.

Phase 1 — Should this even be Playwright? (decision gate)

Playwright's API mode is great for API-as-setup and modest, same-stack API-as-SUT suites that share types/fixtures with the UI tests. It is overkill for a large pure-API suite — it carries browser tooling you don't use and its reporting is trace-oriented.

Recommend a backend-native tool instead, and stop, when ALL of these hold:

  • the API is the primary system under test (not just setup for UI), AND
  • the suite is large / will grow large, AND
  • the backend is not TypeScript (or is owned by a backend team).

Then point to: pytest + httpx + Pydantic (Python), RestAssured (Java), Vitest + Zod (Node, no browser), or Schemathesis / Dredd (property/contract testing straight from OpenAPI).

Otherwise, proceed here.

Phase 2 — Source the contract

OpenAPI / Swagger is the source of truth. No docs → capture the live shape as a fallback and flag it in the proposal. Never invent fields.

Salesforce: there is no OpenAPI. The contract is the org's own metadata (sobjects/<Object>/describe), it drifts without a deploy, and schemas are generated, not hand-written. Load salesforce-metadata-contract — it replaces this phase for org data access. Custom Apex REST endpoints are your own code, so the rest of this skill applies to them in full.

Phase 3 — Schemas (see type-safety)

One z.strictObject per response; export schema + inferred type. Reuse _error.schema.ts for errors.

Phase 4 — Write the tests

  • One test.describe per method + path; tag every test @api.
  • Validate every body: const { data } = await api.post(path, { data, schema: UserSchema }) — api throws on drift. Or expect(Schema.parse(body)).toBeTruthy().
  • Paths from enums/ via buildPath; URLs/tokens from process.env. Never hardcode.
  • Happy-path payloads from Faker factories; invalid inputs from static tiers (data-strategy).
  • Shared setup reused in 3+ files → promote to a helper fixture (fixtures); else use api directly.

Phase 5 — Cover the status matrix (per endpoint)

200/201, 400/422 (validation), 401 (unauth), 403 (forbidden), 404 (missing), 409 (conflict), 204 (no content) — plus every code the spec lists. Multi-call tests → each call in its own test.step.

Phase 6 — Per-field negative coverage

Not just "empty body → 400". Loop each required field omitted, and each field with invalid types (for…of over INVALID_*). Fuzz path params. Hand malicious inputs to security-testing.

Phase 7 — Behavior ≠ spec

Write the test as the spec says, test.skip it with // FIXME: <ticket-url>. Never loosen the schema to make a test pass — drift is a bug to file.

Checklist

  • Phase-1 gate considered (Playwright is the right tool here).
  • Every response validated against a z.strictObject schema.
  • Full status matrix + per-field negatives.
  • Paths via enums, secrets via env. One @api tag per test.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.