Skip to main content

generating-api-tests

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

Source facts

Repository
GoogleCloudPlatform/devrel-demos
Last source activity
April 28, 2026 at 13:27
Detected SKILL.md language
English
Stars
397
Forks
191

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

Showing SKILL.md

SKILL.md
Source instructions · Read-only preview
name
generating-api-tests
description
Reads API_Contracts.md and generates failing Vitest integration tests for the expected Next.js Route Handlers. Use when generating API tests for TDD.
## 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.*
View on GitHub