agentleFS
lintangknittolintangknitto/agent-skills/skills/api-testing/SKILL.md

api-testing

Skill0 starsChanged 2 months agoMITView on GitHub

Use when writing or running backend/API tests that hit HTTP endpoints directly (no browser) — REST or GraphQL, via Supertest/Vitest (TS/JS) or httpx/pytest (Python). Decides, per test, whether to use a mock database, a real database with transaction rollback, or a real database hit black-box over HTTP with an explicit teardown script — and never lets test data linger uncleaned. Also covers the case where the flow under test depends on an entity owned by another repo/service (e.g. testing order-cancellation when order-creation lives elsewhere) — this skill stops and asks for that dependency instead of guessing its shape. Not for browser-driven E2E (use webapp-testing/e2e-testing) or React component tests (use react-testing).

17 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use visual-testing, mobile-testing and 2 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

    visual-testing

    Implement visual regression testing with Playwright screenshots, Chromatic, Percy, and Argos CI. Covers baseline management, diff threshold tuning, dynamic content masking, responsive viewport testing, and review/approval workflows. Use when: "visual test," "screenshot," "visual regression," "pixel diff," "snapshot diff," "update baselines," "Chromatic," "percy snapshot," "argos screenshot." Not for: bulk baseline regeneration after a redesign broke many tests — use selector-drift-recovery; cross-browser rendering matrices — use cross-browser-testing; general Playwright test structure — use playwright-automation. Related: playwright-automation, ci-cd-integration, cross-browser-testing.

    Also in 3 projects that use this

  • petrkindlmannSkill

    mobile-testing

    Test native, React Native, hybrid, and Flutter mobile apps with Appium 3.x, Detox, Maestro, and Patrol. Covers device farm setup (BrowserStack, Sauce Labs), gesture simulation, deep link and cold-start testing, push notifications, biometric (Face ID) auth, offline/poor-network simulation, and iOS/Android permission dialog handling. Use when: "mobile test," "Appium," "Detox," "Maestro," "Patrol," "Flutter test," "iOS test," "Android test," "device farm," "deep link," "biometric," "Face ID," "permission dialog," "React Native test." Not for: device/browser matrix strategy in the abstract — use cross-browser-testing; app startup/memory/battery profiling depth — use performance-testing; mobile screenshot diffing — use visual-testing. Related: ci-cd-integration, cross-browser-testing, performance-testing, test-data-management, test-reliability.

    Also in 3 projects that use this

  • belokonmSkill

    performance-testing

    Performance testing specialist for load testing, stress testing, and performance optimization across applications and infrastructure

    Also in 3 projects that use this

  • GoogleSkill

    code-review

    Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 15 edited versions we read keep these.

  • 4

    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. Distinctive:

    Before writing any test that creates or depends on data (an order, a subscription, a user profile owned by an identity service, etc.), …

    line 40
  2. Distinctive:

    Never insert directly into a table owned by another service's schema as a substitute — you don't know its constraints, triggers, or derived …

    line 56
  3. Very specific:

    If the platform you're on has no interactive question tool available, fall back to asking in plain text rather than silently picking a mode …

    line 76
  4. Distinctive:

    Use the project's existing client if there is one.

    line 89
  5. Very specific:

    Black-box mode: run an explicit teardown that deletes everything tagged with this run's run_id/prefix, in two places:

    line 106
  6. Distinctive:

    Never report a test suite "done" while black-box mode was used and no teardown (automatic or standalone) exists — that's data pollution …

    line 117

“Common” is measured: kept by at least 6 in 10 of the 15 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, no browser)

HTTP-level backend testing — REST/GraphQL endpoints hit directly, no page involved. Covers request/response validation, auth, error handling, and, deliberately, the data-hygiene problem most API-testing guides skip: deciding how the test's data touches the database, and making sure it never leaves residue.

Related skills: for browser-driven flows use webapp-testing (runner + report) or e2e-testing (patterns only). For React component tests, use react-testing. For the scenario list to test before writing specs, run test-case-matrix first.

When to use

  • Writing integration tests for REST/GraphQL endpoints (no browser)
  • Setting up a test DB strategy for a backend project that doesn't have one
  • The flow under test creates/reads data that another service/repo owns

When NOT to use

  • Testing through the browser/UI — use webapp-testing/e2e-testing
  • Testing a React component in isolation — use react-testing

Step 0 — Is every entity this test touches owned by this repo?

Before writing any test that creates or depends on data (an order, a subscription, a user profile owned by an identity service, etc.), check whether the code that owns that entity's creation/validation lives in the repo you're currently working in.

  • If yes (this repo owns it): proceed to Step 1.
  • If no (creation logic lives in another repo/service — e.g. this repo only consumes orders that an order-service elsewhere creates): stop and ask, don't guess. See references/cross-service-test-data.md for the full reasoning; in short, ask the user for one of:

    1. That repo's path (so it can be added as a working directory and its real API/seed mechanism used), or
    2. Its API contract (OpenAPI/Swagger spec, Postman collection), or
    3. A reachable staging/dev endpoint plus test credentials.

    Never insert directly into a table owned by another service's schema as a substitute — you don't know its constraints, triggers, or derived fields, and a "valid-looking" row can still violate that service's actual invariants. Seed through that service's real API (even just to create fixture data) unless it ships its own official seed script.

Step 1 — Choose the database mode for this test

This is conditional per test/suite, not a repo-wide setting — pick based on how the test reaches the code, not preference. Full comparison table and rationale in references/db-strategy-and-cleanup.md. Summary:

ModeUse whenCleanup
Mock/in-memory DBTesting logic, DB behavior itself isn't under testNone needed — instance is disposable
Real DB, transaction rollbackTest runs in-process with the app code (same connection)Wrap in a transaction, roll back at the end
Real DB, black-box over HTTPTest hits a running server (Supertest/httpx against baseURL)Rollback doesn't apply (different connection) — tag + explicit teardown, mandatory

If the platform you're on has no interactive question tool available, fall back to asking in plain text rather than silently picking a mode — same fallback convention this repo's INSTALL.md uses.

Step 2 — Tag test data, always, when using a real DB

Whether transaction-rollback or black-box: give every row this test creates a way to be identified as test data — a run_id generated once per suite run, or a fixed prefix/domain (test_, @e2e.test). Untagged real-DB test data is exactly what makes teardown scripts unreliable later.

Step 3 — Write the test

Use the project's existing client if there is one; otherwise:

  • TS/JS: Supertest + Vitest. Example patterns (request methods, headers, auth tokens, GraphQL queries, error-case assertions) — see references/http-client-patterns.md if present, or the equivalent section in e2e-testing's reference material for shared conventions (POM doesn't apply here, but assertion style does).
  • Python: httpx + pytest (+ FastAPI TestClient if applicable), fixtures for reusable auth/setup.

Cover both success and failure paths, and assert status code first, then response shape.

Step 4 — Cleanup is not optional when a real DB was touched

  • Transaction-rollback mode: rollback happens automatically at test end — verify it actually does (a leaked commit defeats the whole mode).
  • Black-box mode: run an explicit teardown that deletes everything tagged with this run's run_id/prefix, in two places:
    1. Automatic — afterAll/suite teardown, every run.
    2. A standalone script, runnable manually and idempotent (safe to run even if the data's already gone) — for the case where a crashed run never reached its afterAll. See references/db-strategy-and-cleanup.md for the template and assets/cleanup_test_data.py for a ready-to-adapt script.

Never report a test suite "done" while black-box mode was used and no teardown (automatic or standalone) exists — that's data pollution left for someone else to discover later.

Referensi

  • references/cross-service-test-data.md — provider-contract reasoning, what to ask for and why, and why not to insert directly into another service's tables
  • references/db-strategy-and-cleanup.md — full mock/rollback/black-box comparison, tagging convention, standalone cleanup script template
  • assets/cleanup_test_data.py — adaptable standalone teardown script (stdlib-only Python, HTTP-based deletion against the app's own API)

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.