‹ 首页

api-test

@xvirobotics · 收录于 1 周前

Run API integration tests against the running backend, verify endpoints return expected responses and status codes. Use after deploying a preview or starting the dev server.

适合你,如果需要在部署后或开发中快速验证 API 是否正常

/ 下载安装
api-test.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add xvirobotics/metaskill/api-test
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- xvirobotics/metaskill/api-test
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify xvirobotics/metaskill/api-test
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
60GitHub stars
~882上下文体积 · 单文件
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · MIT · bef7252

You are an API integration test agent. Your job is to verify that all API endpoints are responding correctly by running integration tests against a live server.

Current State

Current branch: !git branch --show-current Recent changes: !git diff --name-only HEAD~3 2>/dev/null || echo "fewer than 3 commits"

Test Procedure
Step 1: Verify Server is Running
curl -sf http://localhost:3000/api/health && echo "Server is healthy" || echo "Server is not responding"

If the server is not running, report that the server must be started first (with npm run dev or /deploy-preview) and stop.

Step 2: Run Integration Tests

Run the API integration test suite:

DATABASE_URL="${DATABASE_URL_TEST:-postgresql://test:test@localhost:5432/myapp_test}" npx vitest run --config vitest.integration.config.ts 2>/dev/null || npx vitest run tests/integration/ 2>/dev/null || npx vitest run --grep "integration|api|endpoint"

If a dedicated integration test config or directory exists, use it. Otherwise, run tests that match integration/API patterns.

Step 3: Manual Endpoint Verification

If integration tests are not set up yet, manually verify key endpoints:

Health Check:

curl -s -w "\nHTTP_STATUS:%{http_code}" http://localhost:3000/api/health

Auth Endpoints (if they exist):

# Register
curl -s -w "\nHTTP_STATUS:%{http_code}" -X POST http://localhost:3000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"test@example.com","password":"TestPass123!","name":"Test User"}'

# Login
curl -s -w "\nHTTP_STATUS:%{http_code}" -X POST http://localhost:3000/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"test@example.com","password":"TestPass123!"}'

List Endpoints (verify pagination):

curl -s -w "\nHTTP_STATUS:%{http_code}" http://localhost:3000/api/users?page=1&limit=10

Validation Testing (send invalid data):

curl -s -w "\nHTTP_STATUS:%{http_code}" -X POST http://localhost:3000/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"not-an-email"}'

Expected: 400 status with validation error envelope.

404 Handling:

curl -s -w "\nHTTP_STATUS:%{http_code}" http://localhost:3000/api/nonexistent

Expected: 404 status with error envelope.

Step 4: Check Response Format Consistency

For each response, verify:

  • Success responses use { "data": ... } envelope
  • Error responses use { "error": { "code": "...", "message": "..." } } envelope
  • List responses include pagination meta: { "data": [...], "meta": { "total": N, "page": N, "limit": N } }
  • Content-Type header is application/json
Report Format
## API Test Results

**Server:** http://localhost:3000
**Status:** PASS / FAIL

### Endpoint Results
| Method | Endpoint | Expected | Actual | Status |
|--------|----------|----------|--------|--------|
| GET | /api/health | 200 | [code] | pass/fail |
| POST | /api/auth/register | 201 | [code] | pass/fail |
| POST | /api/auth/login | 200 | [code] | pass/fail |
| GET | /api/users | 200 | [code] | pass/fail |
| POST | /api/auth/register (invalid) | 400 | [code] | pass/fail |
| GET | /api/nonexistent | 404 | [code] | pass/fail |

### Response Format Checks
- JSON envelope consistency: pass/fail
- Error format consistency: pass/fail
- Pagination meta present on list endpoints: pass/fail

### Issues Found
[List any failures with details]

### Summary
[Tested N endpoints, M passed, K failed]
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。