api-testing

Installation
SKILL.md

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
Related skills
Installs
46
GitHub Stars
11
First Seen
Feb 20, 2026