api-testing

Tests HTTP APIs with Supertest for TypeScript and httpx with pytest for Python.

Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aicodepro/ai-agent-nexi --skill api-testing-aicodepro
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: api-testing
Source: https://github.com/aicodepro/ai-agent-nexi/tree/main/agent/skills/api-testing
Command: npx skills add https://github.com/aicodepro/ai-agent-nexi --skill api-testing-aicodepro

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires supertest, httpx, pytest.

What problem does it solve? Writing reliable tests for REST and GraphQL APIs requires knowing the right patterns for request building, authentication, response validation, and error handling across different languages and frameworks, which is time-consuming to set up from scratch. ## Core Features & Use Cases - Supertest patterns for TypeScript/JavaScript: Covers GET, POST, PUT, DELETE requests, headers, query parameters, authentication tokens, and error response validation with vitest. - httpx and pytest patterns for Python: Includes TestClient setup, fixtures for auth tokens, and file upload testing for FastAPI-style applications. - GraphQL and performance testing: Demonstrates querying GraphQL endpoints with variables and asserting response time thresholds. - Use Case: When building a new Express or FastAPI endpoint, use these patterns to quickly write tests that verify status codes, response body structure, authentication rejection, and validation error formats before shipping. ## Quick Start Ask the AI to write API tests for your endpoint, for example: write Supertest tests for my Express user registration endpoint covering success, validation errors, and authentication.

Frequently Asked Questions about api-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test a REST API with Supertest?

Import supertest and pass your Express app to request(app), then chain methods like .get(), .post(), .send(), and .expect() to assert status codes. Use expect() on response.body to validate the returned JSON structure.

How to test FastAPI endpoints with pytest?

Use FastAPI's TestClient to create a client from your app, then call client.get() or client.post() with JSON payloads. Assert on response.status_code and response.json() to verify behavior, and use pytest fixtures for shared setup like auth tokens.

Supertest vs httpx for API testing?

Supertest is the standard choice for TypeScript/JavaScript apps like Express, while httpx with pytest or FastAPI's TestClient is the Python equivalent. Both support in-process testing without running a live server.

How do I test authenticated API endpoints?

Log in via a POST to your auth endpoint in a beforeAll hook or pytest fixture, extract the token from the response, then pass it as an Authorization Bearer header on subsequent requests. Also test that requests without a token return 401.

Can I test GraphQL APIs with Supertest?

Yes, send a POST request to your GraphQL endpoint with the query string and variables in the request body. Assert on response.body.data to verify the returned fields match expected values.

Why do my API tests fail between runs?

Tests often fail due to shared database state leaking between test cases. Reset the database between tests, group related endpoints in describe blocks, and mock external services to keep tests deterministic.