agentleFS
Google CloudKnown publisherGoogleCloudPlatform/devrel-demos/other/modernizing-expressjs/.agents/skills/generating-api-tests/SKILL.md

generating-api-tests

Skill378 starsChanged 4 months agoApache-2.0View on GitHub

Reads API_Contracts.md and generates failing Vitest integration tests for the expected Next.js Route Handlers. Use when generating API tests for TDD.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    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:

    Create a tests/api folder.

    line 23
  2. Very specific:

    Use node-mocks-http to construct the Request and capture the Next.js NextResponse JSON output.

    line 26

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “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

Objective

Implement Test-Driven Development (TDD) by writing strict tests asserting the exact behaviors, payloads, and JSON responses defined in the legacy Express APIs.

Instructions for the Scaffold Subagent

Copy this checklist and track your progress:

Task Progress:
- [ ] Step 1: Read the API Contracts
- [ ] Step 2: Generate Auth/User Tests
- [ ] Step 3: Generate Article/Comment Tests

Step 1. Read the Specs:

Locate and read docs/legacy-audit/API_Contracts.md and docs/legacy-audit/Business_Logic_Rules.md.

Step 2. Generate Test Suites:

Create a tests/api folder. For each distinct domain in the contracts (e.g., users.test.ts, articles.test.ts), write a Vitest suite.

Step 3. Mocking:

Use node-mocks-http to construct the Request and capture the Next.js NextResponse JSON output. Assert that the required HTTP status codes (200, 201, 401, 404, 422) and JSON body structures match the original Express requirements.

Crucial Note: These tests WILL FAIL initially. That is the point of TDD. They will be executed repeatedly during the Data and API scaffolding phases until they pass.

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.