route-tester
Skill0 starsChanged 8 months agoMITView on GitHub
Framework-agnostic HTTP API route testing patterns, authentication strategies, and integration testing best practices. Supports REST APIs with JWT cookie authentication and other common auth patterns.
- Reads credentials
3 other projects use a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- michelve/hugin-coworkedited, first seen Mar 16, 2026
- serithemage/claude-code-demotheir own version, first seen Dec 10, 2025
- weirdgme/Claude-code-infrastructure-showcasetheir own version, first seen Nov 3, 2025
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 1
- michelve/hugin-cowork★ 194% same
Wrote their own version · 2
- serithemage/claude-code-demo★ 4same name
- weirdgme/Claude-code-infrastructure-showcase★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository30 other files it gives its agents.
- skills/react-best-practices/AGENTS.mdAGENTS.md
- accessibilitySkill
- adr-writerSkill
- automatic-code-reviewSkill
- component-visualizerSkill
- create-tasksSkill
- dsai-componentsSkill
- dsai-figmaSkill
- dsai-stylingSkill
- dsai-toolsSkill
- figma-code-connect-componentsSkill
- figma-create-design-system-rulesSkill
- figma-create-new-fileSkill
- figma-generate-designSkill
- figma-generate-librarySkill
- figma-implement-designSkill
- figma-useSkill
- miro-mcpSkill
- nodejsSkill
- playwright-skillSkill
- prismaSkill
- react-best-practicesSkill
- reactSkill
- setupSkill
- skill-creatorSkill
- skill-developerSkill
- sync-schemasSkill
- task-checkSkill
- web-design-guidelinesSkill
- writing-testsSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 10 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
10
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 34
Test individual route handlers in isolation
- Distinctive: line 41
Test full request/response cycle
- Distinctive: line 48
Test from client perspective
- Distinctive: line 139
Use descriptive test names: - Test names should describe the scenario and expected outcome
- Distinctive: line 142
Use realistic test data: - Test data should mimic production data
- Distinctive: line 143
Clean up after tests: - Always reset state between tests
- Distinctive: line 144
Mock external dependencies: - Don't call real external APIs in tests
- Distinctive: line 146
Validate response schemas: - Ensure APIs return expected structure
- Distinctive: line 147
Test rate limiting: - Verify rate limits work correctly
- Distinctive: line 148
Test CORS headers: - Ensure CORS is configured correctly
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Current Project Context
!`cat package.json 2>/dev/null || echo '{"error": "No package.json found."}'`API Route Testing Skill
This skill provides guidance for testing HTTP API routes and endpoints. Primary examples use Express with TypeScript, but patterns adapt to other frameworks.
When to Use
- Testing API endpoints
- Writing integration tests for Express routes
- Testing authentication flows (JWT cookies, sessions)
- Validating API responses and status codes
- Testing route middleware and error handling
- Creating route test suites
Core Testing Principles
1. Test Types for API Routes
Unit Tests
- Test individual route handlers in isolation
- Mock dependencies (database, external APIs)
- Fast execution (< 50ms per test)
- Focus on business logic
Integration Tests
- Test full request/response cycle
- Real database (test instance)
- Authentication flow included
- Slower but more comprehensive
End-to-End Tests
- Test from client perspective
- Full authentication flow
- Real services (or close replicas)
- Most realistic, slowest execution
2. Authentication Testing Patterns
See authentication-testing.md for JWT cookie and bearer token authentication test patterns.
3. HTTP Method Testing
See http-method-patterns.md for GET, POST, PUT/PATCH, and DELETE request test examples.
4. Response Validation
See response-validation.md for status code testing and response schema validation patterns.
5. Error Handling Tests
describe("Error Handling", () => {
it("should return structured error response", async () => {
const response = await request(app).post("/api/users").send({ invalid: "data" });
expect(response.status).toBe(400);
expect(response.body).toEqual({
error: expect.any(String),
message: expect.any(String),
errors: expect.any(Array),
});
});
it("should handle database errors gracefully", async () => {
mockDatabase.findOne.mockRejectedValue(new Error("Connection lost"));
const response = await request(app).get("/api/users/123");
expect(response.status).toBe(500);
expect(response.body.error).toBe("Internal Server Error");
});
it("should sanitize error messages in production", async () => {
process.env.NODE_ENV = "production";
const response = await request(app).get("/api/error-prone-route");
expect(response.status).toBe(500);
expect(response.body.message).not.toContain("stack trace");
expect(response.body.message).not.toContain("SQL");
});
});6. Test Setup and Teardown
describe("API Tests", () => {
let testDatabase;
beforeAll(async () => {
// Initialize test database
testDatabase = await initTestDatabase();
});
afterAll(async () => {
// Clean up test database
await testDatabase.close();
});
beforeEach(async () => {
// Seed test data
await testDatabase.seed();
});
afterEach(async () => {
// Clear test data
await testDatabase.clear();
});
// Tests...
});Framework-Specific Testing Libraries
While this skill provides framework-agnostic patterns, here are common testing libraries per framework:
- Express: supertest, vitest
Best Practices
- Use descriptive test names - Test names should describe the scenario and expected outcome
- Test happy path and edge cases - Cover both success and failure scenarios
- Isolate tests - Each test should be independent and not rely on other tests
- Use realistic test data - Test data should mimic production data
- Clean up after tests - Always reset state between tests
- Mock external dependencies - Don't call real external APIs in tests
- Test authentication edge cases - Expired tokens, invalid tokens, missing tokens
- Validate response schemas - Ensure APIs return expected structure
- Test rate limiting - Verify rate limits work correctly
- Test CORS headers - Ensure CORS is configured correctly
Common Pitfalls
❌ Don't share state between tests
// Bad
let userId;
it("creates user", async () => {
const response = await request(app).post("/api/users").send(userData);
userId = response.body.id; // Shared state!
});
it("deletes user", async () => {
await request(app).delete(`/api/users/${userId}`); // Depends on previous test
});✅ Do create fresh state for each test
// Good
it("creates user", async () => {
const response = await request(app).post("/api/users").send(userData);
expect(response.status).toBe(201);
});
it("deletes user", async () => {
const user = await createTestUser();
const response = await request(app).delete(`/api/users/${user.id}`);
expect(response.status).toBe(204);
});Additional Resources
See the resources/ directory for more detailed guides:
http-testing-fundamentals.md- Deep dive into HTTP testing conceptsauthentication-testing.md- Authentication strategies and edge casesapi-integration-testing.md- Integration testing patterns and tools
Quick Reference
Test Structure
describe('Resource Name', () => {
describe('HTTP Method /path', () => {
it('should describe expected behavior', async () => {
// Arrange
const testData = {...};
// Act
const response = await request(app)
.method('/path')
.set('Cookie', authCookie)
.send(testData);
// Assert
expect(response.status).toBe(expectedStatus);
expect(response.body).toMatchObject(expectedData);
});
});
});Authentication Pattern
let authCookie: string;
beforeEach(async () => {
const response = await request(app)
.post('/api/auth/login')
.send({ email: 'test@example.com', password: 'password123' });
authCookie = response.headers['set-cookie'][0];
});
// Use authCookie in protected route tests
.set('Cookie', authCookie)Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

