Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
secondsky avatar

Api Testing

  • 695 installs
  • 196 repo stars
  • Updated July 25, 2026
  • secondsky/claude-skills

api-testing is a Claude Code skill that teaches developers to write and structure HTTP API tests using Supertest with Vitest in TypeScript and httpx with pytest in Python for REST, GraphQL, authentication, and error-case

About

api-testing is a secondsky Claude skill that encodes expert patterns for HTTP API testing in two stacks: Supertest with Vitest or Bun in TypeScript and JavaScript, and httpx with pytest in Python. The skill walks through installation commands such as bun add -d supertest @types/supertest, basic request setup against an app instance, and scenarios for REST endpoints, GraphQL queries, auth headers, and error responses. Developers reach for api-testing when scaffolding integration tests for Express, Fastify, or FastAPI services and need consistent request/response assertion structure. The skill allows Bash, Read, Edit, Write, Grep, and Glob so agents can install deps, read route files, and generate test files in place.

  • Dual-stack patterns: Supertest with Vitest (TypeScript) and httpx with pytest (Python)
  • REST examples for GET/POST, body validation, and expected status assertions
  • Request helpers for headers, auth, and error-path expectations (e.g., 400 on missing fields)
  • Install snippets for Bun/npm dev dependencies including @types/supertest
  • Covers GraphQL, authentication, and error-handling testing themes in the skill charter

Api Testing by the numbers

  • 695 all-time installs (skills.sh)
  • +22 installs in the week ending Jul 27, 2026 (Skillselion tracking)
  • Ranked #574 of 2,159 Testing & QA skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/secondsky/claude-skills --skill api-testing

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs695
repo stars196
Security audit3 / 3 scanners passed
Last updatedJuly 25, 2026
Repositorysecondsky/claude-skills

How do you test REST APIs with Supertest and pytest?

Write and structure HTTP API tests with Supertest (TypeScript) or httpx/pytest (Python) for REST, GraphQL, auth, and error cases.

Who is it for?

Backend developers shipping Node or Python HTTP services who need structured integration tests for REST, GraphQL, and authentication flows.

Skip if: Teams needing browser E2E UI tests or load-testing benchmarks instead of HTTP integration coverage.

When should I use this skill?

A user asks to write API tests, set up Supertest, test REST or GraphQL endpoints, or validate auth and error handling with pytest httpx.

What you get

Typed API test files with Supertest or httpx request suites, auth fixtures, and error-case assertions ready for Vitest or pytest runs.

  • API integration test files
  • auth and error-case test suites

By the numbers

  • Supports 2 language stacks: TypeScript Supertest and Python httpx/pytest

Files

SKILL.mdMarkdownGitHub ↗

API Testing

Expert knowledge for testing HTTP APIs with Supertest (TypeScript/JavaScript) and httpx/pytest (Python).

TypeScript/JavaScript (Supertest)

Installation

# Using Bun
bun add -d supertest @types/supertest

# or: npm install -D supertest @types/supertest

Basic Setup

import { describe, it, expect } from 'vitest'
import request from 'supertest'
import { app } from './app'

describe('API Tests', () => {
  it('returns health status', async () => {
    const response = await request(app)
      .get('/api/health')
      .expect(200)

    expect(response.body).toEqual({ status: 'ok' })
  })

  it('creates a user', async () => {
    const response = await request(app)
      .post('/api/users')
      .send({ name: 'John Doe', email: 'john@example.com' })
      .expect(201)

    expect(response.body).toMatchObject({
      id: expect.any(Number),
      name: 'John Doe',
    })
  })

  it('validates required fields', async () => {
    await request(app)
      .post('/api/users')
      .send({ name: 'John Doe' })
      .expect(400)
  })
})

Request Methods

// GET
await request(app).get('/api/users').expect(200)

// POST with body
await request(app)
  .post('/api/users')
  .send({ name: 'John' })
  .expect(201)

// PUT
await request(app)
  .put('/api/users/1')
  .send({ name: 'Jane' })
  .expect(200)

// DELETE
await request(app).delete('/api/users/1').expect(204)

Headers and Query Parameters

// Set headers
await request(app)
  .get('/api/protected')
  .set('Authorization', 'Bearer token123')
  .expect(200)

// Query parameters
await request(app)
  .get('/api/users')
  .query({ page: 1, limit: 10 })
  .expect(200)

Authentication Testing

describe('Authentication', () => {
  let authToken: string

  beforeAll(async () => {
    const response = await request(app)
      .post('/api/auth/login')
      .send({ email: 'user@example.com', password: 'password123' })
      .expect(200)

    authToken = response.body.token
  })

  it('accesses protected endpoint', async () => {
    await request(app)
      .get('/api/protected')
      .set('Authorization', `Bearer ${authToken}`)
      .expect(200)
  })

  it('rejects without token', async () => {
    await request(app).get('/api/protected').expect(401)
  })
})

Error Handling

it('handles validation errors', async () => {
  const response = await request(app)
    .post('/api/users')
    .send({ email: 'invalid-email' })
    .expect(400)

  expect(response.body).toMatchObject({
    error: 'Validation failed',
    details: expect.any(Array),
  })
})

it('handles not found', async () => {
  await request(app).get('/api/users/999999').expect(404)
})

Python (httpx + pytest)

Installation

uv add --dev httpx pytest-asyncio

Basic Setup

import pytest
from fastapi.testclient import TestClient
from main import app

client = TestClient(app)

def test_health_check():
    response = client.get("/api/health")
    assert response.status_code == 200
    assert response.json() == {"status": "ok"}

def test_create_user():
    response = client.post(
        "/api/users",
        json={"name": "John Doe", "email": "john@example.com"}
    )
    assert response.status_code == 201
    data = response.json()
    assert data["name"] == "John Doe"
    assert "id" in data

def test_not_found():
    response = client.get("/api/users/999")
    assert response.status_code == 404

Fixtures

@pytest.fixture
def auth_token(client):
    response = client.post(
        "/api/auth/login",
        json={"email": "user@example.com", "password": "password123"}
    )
    return response.json()["token"]

def test_protected_endpoint(client, auth_token):
    response = client.get(
        "/api/protected",
        headers={"Authorization": f"Bearer {auth_token}"}
    )
    assert response.status_code == 200

File Upload

def test_file_upload(client, tmp_path):
    test_file = tmp_path / "test.txt"
    test_file.write_text("test content")

    with open(test_file, "rb") as f:
        response = client.post(
            "/api/upload",
            files={"file": ("test.txt", f, "text/plain")}
        )

    assert response.status_code == 200

GraphQL Testing

it('queries GraphQL endpoint', async () => {
  const query = `
    query GetUser($id: ID!) {
      user(id: $id) { id name email }
    }
  `

  const response = await request(app)
    .post('/graphql')
    .send({ query, variables: { id: '1' } })
    .expect(200)

  expect(response.body.data.user).toMatchObject({
    id: '1',
    name: expect.any(String),
  })
})

Performance Testing

it('responds within acceptable time', async () => {
  const start = Date.now()
  await request(app).get('/api/users').expect(200)
  const duration = Date.now() - start
  expect(duration).toBeLessThan(100) // 100ms threshold
})

Best Practices

  • Group related endpoints in describe blocks
  • Reset database between tests
  • Validate status codes first
  • Check response structure
  • Test error message format
  • Mock external services
  • Test both happy path and error cases

See Also

  • vitest-testing - Unit testing framework
  • playwright-testing - E2E API testing
  • test-quality-analysis - Test quality patterns

Related skills

How it compares

Pick api-testing over generic unit-test skills when the task is HTTP request/response integration coverage rather than component or E2E browser tests.

FAQ

Which frameworks does api-testing cover?

api-testing covers Supertest with Vitest or Bun for TypeScript and JavaScript, and httpx with pytest for Python. Both stacks address REST APIs, GraphQL, authentication, and error handling patterns.

How do you install Supertest for api-testing?

api-testing documents bun add -d supertest @types/supertest or npm install -D supertest @types/supertest. Tests import request from supertest and target the exported app instance.

What API scenarios does api-testing test?

api-testing structures tests for REST endpoints, GraphQL queries, request and response validation, authentication flows, and HTTP error cases. Agents use Bash and file tools to scaffold tests in the repo.

Is Api Testing safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

Testing & QAtestingbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.