#601

Global Rank · of 601 Skills

api-testing AI Agent Skill

View Source: oakoss/agent-skills

Safe

Installation

npx skills add oakoss/agent-skills --skill api-testing

42

Installs

API Testing

Overview

API testing validates HTTP endpoints by sending requests and asserting responses, covering status codes, headers, body content, and error handling. Supertest provides a fluent chainable API for integration testing against Express, Fastify, and Hono apps without starting a real server. MSW (Mock Service Worker) v2 intercepts outgoing HTTP requests at the network level, enabling realistic mocking of external services in both Node.js tests and browser environments.

When to use: Integration tests for REST APIs, testing middleware pipelines, validating request/response contracts, mocking third-party APIs in tests, testing error handling and edge cases.

When NOT to use: Unit testing pure functions (use direct assertions), E2E browser testing (use Playwright/Cypress), load/performance testing (use k6/Artillery), testing static file serving.

Quick Reference

Pattern API Key Points
GET request request(app).get('/path') Returns supertest Test object
POST with body request(app).post('/path').send(body) Automatically sets Content-Type
Auth header .set('Authorization', 'Bearer token') Chain before .expect()
Status assertion .expect(200) Chainable with body assertions
Body assertion .expect({ key: 'value' }) Deep equality check
Header assertion .expect('Content-Type', /json/) Accepts string or regex
MSW HTTP handler http.get('/api/users', resolver) Intercepts matching requests
MSW GraphQL handler graphql.query('GetUser', resolver) Intercepts by operation name
MSW response HttpResponse.json(data, { status }) v2 response format
MSW error simulation HttpResponse.error() Simulates network failure
MSW one-time handler http.get(path, resolver, { once: true }) Auto-removed after first match
MSW per-test override server.use(handler) Override default handlers in specific tests
Schema validation schema.parse(response.body) Validates response structure with Zod
Cookie persistence const agent = request.agent(app) Maintains cookies across requests
Fastify inject app.inject({ method, url }) Built-in testing without supertest
Hono test client testClient(app) Type-safe request builder

Common Mistakes

Mistake Correct Pattern
Not awaiting supertest requests Always await request(app).get('/path')
Sharing server state between tests Reset handlers with server.resetHandlers() in afterEach
Mocking fetch/axios directly Use MSW to intercept at the network level
Forgetting server.listen() in setup Call in beforeAll, resetHandlers in afterEach
Passing Fastify instance to supertest Use fastify.server (the underlying Node server)
Asserting before response completes Use await or return the supertest chain
Hardcoding test data across many tests Use factories or fixtures for test data
Not testing error responses Test 4xx and 5xx paths alongside happy paths
Using server.close() in afterEach Use afterAll for close, afterEach for reset only
Ignoring response headers in assertions Validate Content-Type, Cache-Control, CORS headers
Not using onUnhandledRequest: 'error' Catch unhandled requests to prevent silent test gaps
Testing implementation instead of behavior Assert on response shape, not internal function calls

Delegation

  • Test structure review: Use Task agent
  • Code review: Delegate to code-reviewer agent
  • Pattern discovery: Use Explore agent

If the vitest-testing skill is available, delegate general Vitest configuration and patterns to it.
Otherwise, recommend: npx skills add oakoss/agent-skills --skill vitest-testing

References

Installs

Installs 42
Global Rank #601 of 601

Security Audit

ath Safe
socket Safe
Alerts: 0 Score: 90
snyk Low
EU EU-Hosted Inference API

Power your AI Agents with the best open-source models.

Drop-in OpenAI-compatible API. No data leaves Europe.

Explore Inference API

GLM

GLM 5

$1.00 / $3.20

per M tokens

Kimi

Kimi K2.5

$0.60 / $2.80

per M tokens

MiniMax

MiniMax M2.5

$0.30 / $1.20

per M tokens

Qwen

Qwen3.5 122B

$0.40 / $3.00

per M tokens

How to use this skill

1

Install api-testing by running npx skills add oakoss/agent-skills --skill api-testing in your project directory. Run the install command above in your project directory. The skill file will be downloaded from GitHub and placed in your project.

2

No configuration needed. Your AI agent (Claude Code, Cursor, Windsurf, etc.) automatically detects installed skills and uses them as context when generating code.

3

The skill enhances your agent's understanding of api-testing, helping it follow established patterns, avoid common mistakes, and produce production-ready output.

What you get

Skills are plain-text instruction files — not executable code. They encode expert knowledge about frameworks, languages, or tools that your AI agent reads to improve its output. This means zero runtime overhead, no dependency conflicts, and full transparency: you can read and review every instruction before installing.

Compatibility

This skill works with any AI coding agent that supports the skills.sh format, including Claude Code (Anthropic), Cursor, Windsurf, Cline, Aider, and other tools that read project-level context files. Skills are framework-agnostic at the transport level — the content inside determines which language or framework it applies to.

Data sourced from the skills.sh registry and GitHub. Install counts and security audits are updated regularly.

EU Made in Europe

Chat with 100+ AI Models in one App.

Use Claude, ChatGPT, Gemini alongside with EU-Hosted Models like Deepseek, GLM-5, Kimi K2.5 and many more.

Customer Support