agentleFS
idavidov13idavidov13/agentic-playwright/.agents/skills/api-testing/SKILL.md

api-testing

Skill268 starsChanged 8 days agoMITView on GitHub

Use when writing or updating an API spec under tests/**/api/**, planning coverage for an endpoint, building a response schema from the API contract, or deciding whether API setup/teardown becomes a helper fixture. Not for Zod syntax and type inference (see `type-safety`) or fixture mechanics (see `fixtures`).

  • Reads credentials

17 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 9 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

  • mmondoraSkill

    security-testing

    Automated security testing in CI. SAST, DAST, dependency scanning, authorization testing, secret detection. Use when adding security scans to pipelines, writing tenant isolation tests, or configuring vulnerability scanning.

    Also in 3 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

  • +4 more from petrkindlmann

The file

We split this skill into the rules it gives an agent

10 rules. 0 are common, 1 is distinctive, and 9 are very specific to this project.

  • 0

    Common

    Most of the 13 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 9

    Very specific

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

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

    Never hardcode API URLs, access tokens, emails, passwords or endpoint paths: only process.env.API_URL, process.env.ACCESS_TOKEN, …

    line 10
  2. Very specific:

    Never change an expected status, loosen a schema or drop a test: keep it as the contract says, wrapped in test.skip with // FIXME: …

    line 22
  3. Very specific:

    Every request-body endpoint gets an empty-body test, a per-field omission loop and a per-field invalid-type for...of loop over the …

    line 32
  4. Distinctive:

    Always fuzz path parameters with the invalid-format loop, documented or not.

    line 33
  5. Very specific:

    Call apiRequest directly in tests and hooks.

    line 34
  6. Very specific:

    Write the response schema in fixtures/api/schemas/{area}/ per type-safety (ls fixtures/api/schemas/ resolves {area}).

    line 39
  7. Very specific:

    Add a new path to ApiEndpoints per enums.

    line 40
  8. Very specific:

    Write the happy path: apiRequest<SchemaType>({ method, url: ApiEndpoints.X, baseUrl: process.env.API_URL, headers: …

    line 41
  9. Very specific:

    Add the negative loops from references/negative-testing.md.

    line 43
  10. Very specific:

    Run npx playwright test <file> and npm run lint.

    line 45

“Common” is measured: kept by at least 6 in 10 of the 13 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

Critical

  • Never hardcode API URLs, access tokens, emails, passwords or endpoint paths: only process.env.API_URL, process.env.ACCESS_TOKEN, process.env.APP_EMAIL / APP_PASSWORD and ApiEndpoints from enums/{area}/*.
  • Schemas and tests come from the documented contract (OpenAPI / Swagger), never from a request made first; no document found: stop and ask.
  • Assert every response body with expect(SchemaName.parse(body)).toBeTruthy();, not a generic or a bare parse; in fixture code, with no test to assert in, const x = SchemaName.parse(body);. Never as-cast.

    // CORRECT
    expect(UserResponseSchema.parse(body)).toBeTruthy();
    // WRONG
    const user = body as UserResponse;
  • A test with more than one API call wraps each call in its own test.step(), assertions inside the step.
  • Never change an expected status, loosen a schema or drop a test: keep it as the contract says, wrapped in test.skip with // FIXME: <ticket-url>. 422 where the spec says 400 is still a mismatch; only a human confirming the spec is stale changes the expectation.

    // CORRECT
    // FIXME: <ticket-url> spec 422, API 500
    test.skip('returns 422 for bad price', { tag: '@api' }, async () => {});
    // WRONG
    expect(status).toBe(500);
  • Every request-body endpoint gets an empty-body test, a per-field omission loop and a per-field invalid-type for...of loop over the INVALID_* arrays; never empty-body-only.
  • Always fuzz path parameters with the invalid-format loop, documented or not.
  • Call apiRequest directly in tests and hooks; promote to a helper fixture in fixtures/helper/helper-fixture.ts only when the same setup/teardown is copy-pasted into 3+ test files (canonical threshold, other skills point here).

Procedure

  1. Locate the contract: a spec file in the repo, the API host's documentation route, or a document from the human. Nothing found: ask. Partial or absent: references/contract-sourcing.md.
  2. Write the response schema in fixtures/api/schemas/{area}/ per type-safety (ls fixtures/api/schemas/ resolves {area}); error bodies use fixtures/api/schemas/util/errorResponseSchema.ts.
  3. Add a new path to ApiEndpoints per enums.
  4. Write the happy path: apiRequest<SchemaType>({ method, url: ApiEndpoints.X, baseUrl: process.env.API_URL, headers: process.env.ACCESS_TOKEN, body }) in a test.describe per method + path, tag @api, payload from a factory per data-strategy.
  5. List every status code the contract documents plus the baseline rows in references/coverage-matrix.md; present the plan before writing those tests.
  6. Add the negative loops from references/negative-testing.md; a test with several calls follows references/multi-call-steps.md.
  7. Setup or teardown past the threshold goes to references/helper-fixtures.md; below it, beforeAll/afterAll in the spec with apiRequest.
  8. Run npx playwright test <file> and npm run lint. A response that disagrees with the contract: test.skip + // FIXME; red for another reason: debugging.

References

  • references/contract-sourcing.md: open when the contract is partial, missing or unversioned.
  • references/coverage-matrix.md: the status-code rows every endpoint × method needs, the describe structure, the token conventions.
  • references/negative-testing.md: the per-field invalid-type, omission, path-parameter and query-parameter loops.
  • references/multi-call-steps.md: the create → read test.step() pattern with cleanup.
  • references/helper-fixtures.md: the setup → use() → teardown pattern for promoted API setup.

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.