Overview
API testing for REST and GraphQL endpoints. Covers contract testing, schema validation, authentication testing, error handling, and performance assertions.
Capabilities
- Write API contract tests for REST and GraphQL
- Validate response schemas and status codes
- Test authentication and authorization flows
- Check rate limiting and error handling
- Automate API regression testing in CI
When to Use
Trigger phrases:
"api testing"
"REST and GraphQL API testing — contract testing, schema validation, and integrat"
Building or consuming REST/GraphQL APIs
Need to verify API contracts between services
API breaking changes need detection before deploy
Testing auth flows and permission boundaries
When NOT to Use
- Task is about deployment, not development (use deploy skills)
- Task is about code review, not writing (use review skills)
- You need to understand existing code first (use research skills)
- Task is about testing only (use test skills)
- Requirements are unclear (clarify first)
- Task is trivially simple (single line fix)
Pseudo Code
The api-testing workflow follows a standard pipeline pattern.
Core flow:
# api-testing primary flow
input = prepare(raw_data)
result = process(input, config={api, automation, contract, graphql, integration})
validate(result)
deliver(result)
Error handling:
on error:
log(error_details)
retry_with_backoff(max=3)
if still_failing: alert_and_escalate()
REST Contract Test
def test_user_api_contract(response):
assert response.status_code == 200
assert response.json() == {
"id": int,
"email": str,
"name": str,
"created_at": str # ISO 8601
}
GraphQL Test
def test_graphql_query():
query = """
query GetUser($id: ID!) {
user(id: $id) { id name email }
}
"""
result = graphql_execute(query, variables={"id": "1"})
assert result["data"]["user"]["id"] == "1"
Common Patterns
- Contract first: Define API schema before implementation
- Status code coverage: Test 200, 201, 400, 401, 403, 404, 500
- Auth boundary tests: Verify protected endpoints reject unauthenticated requests
- Idempotency tests: POST requests should be safe to retry
How to Use
- Understand the requirement and existing codebase patterns
- Design the solution with error handling and testability in mind
- Implement incrementally with tests for each change
- Verify against expected outcomes (manual and automated)
- Document usage, edge cases, and integration points
- Review with team before merging to shared branches
Red Flags
- Skipping tests to ship faster: Untested code breaks in production when you least expect it
- No error handling in production code: Unhandled errors crash services and lose user data
- Hardcoded configuration values: Hardcoded values prevent environment switching and leak secrets
- Ignoring security implications: Missing input validation, auth bypasses, and injection vulnerabilities
- Over-engineering simple solutions: Premature abstraction adds complexity without proportional benefit
Verification
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization |
Reality |
| "Tests slow me down" |
Bugs slow you down 10x more. Tests are speed, not overhead. |
| "I will refactor later" |
Technical debt compounds. Refactor as you go. |
| "It works on my machine" |
If it is not in CI, it does not work. Ship proof, not claims. |
1---2name: api-testing3description: Use when rEST and GraphQL API testing — contract testing, schema validation,4 and integration test automation. Use when working with api testing.5domain: development6author: oyi777license: Apache-2.08subdomain: software-development9tags:10- api11- coding12- graphql13- rest-api14- software-engineering15- testing16version: 1.0.017category: development18metadata:19 source: https://skillmd.com/skills/oyi77/api-testing20---21222324## Overview2526API testing for REST and GraphQL endpoints. Covers contract testing, schema validation, authentication testing, error handling, and performance assertions.2728## Capabilities2930- Write API contract tests for REST and GraphQL31- Validate response schemas and status codes32- Test authentication and authorization flows33- Check rate limiting and error handling34- Automate API regression testing in CI3536## When to Use37**Trigger phrases:**38- "api testing"39- "REST and GraphQL API testing — contract testing, schema validation, and integrat"404142- Building or consuming REST/GraphQL APIs43- Need to verify API contracts between services44- API breaking changes need detection before deploy45- Testing auth flows and permission boundaries4647## When NOT to Use4849- Task is about deployment, not development (use deploy skills)50- Task is about code review, not writing (use review skills)51- You need to understand existing code first (use research skills)52- Task is about testing only (use test skills)53- Requirements are unclear (clarify first)54- Task is trivially simple (single line fix)555657## Pseudo Code5859The api-testing workflow follows a standard pipeline pattern.6061Core flow:62```63# api-testing primary flow64input = prepare(raw_data)65result = process(input, config={api, automation, contract, graphql, integration})66validate(result)67deliver(result)68```6970Error handling:71```72on error:73 log(error_details)74 retry_with_backoff(max=3)75 if still_failing: alert_and_escalate()76```777879### REST Contract Test80```python81def test_user_api_contract(response):82 assert response.status_code == 20083 assert response.json() == {84 "id": int,85 "email": str,86 "name": str,87 "created_at": str # ISO 860188 }89```9091### GraphQL Test92```python93def test_graphql_query():94 query = """95 query GetUser($id: ID!) {96 user(id: $id) { id name email }97 }98 """99 result = graphql_execute(query, variables={"id": "1"})100 assert result["data"]["user"]["id"] == "1"101```102103## Common Patterns104105- **Contract first**: Define API schema before implementation106- **Status code coverage**: Test 200, 201, 400, 401, 403, 404, 500107- **Auth boundary tests**: Verify protected endpoints reject unauthenticated requests108- **Idempotency tests**: POST requests should be safe to retry109110## How to Use1111121. Understand the requirement and existing codebase patterns1132. Design the solution with error handling and testability in mind1143. Implement incrementally with tests for each change1154. Verify against expected outcomes (manual and automated)1165. Document usage, edge cases, and integration points1176. Review with team before merging to shared branches118119## Red Flags120121- **Skipping tests to ship faster**: Untested code breaks in production when you least expect it122- **No error handling in production code**: Unhandled errors crash services and lose user data123- **Hardcoded configuration values**: Hardcoded values prevent environment switching and leak secrets124- **Ignoring security implications**: Missing input validation, auth bypasses, and injection vulnerabilities125- **Over-engineering simple solutions**: Premature abstraction adds complexity without proportional benefit126127## Verification128129- [ ] Skill output matches expected behavior130131## Process1321331. Analyze the task requirements1342. Apply domain expertise1353. Verify output quality136137## Anti-Rationalization Table138139| Rationalization | Reality |140|---|---|141| "Tests slow me down" | Bugs slow you down 10x more. Tests are speed, not overhead. |142| "I will refactor later" | Technical debt compounds. Refactor as you go. |143| "It works on my machine" | If it is not in CI, it does not work. Ship proof, not claims. |