@intentsolutionsio/api-test-automation 1.0.0 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -216,11 +216,13 @@ describe('GraphQL API', () => {
|
|
|
216
216
|
The agent generates tests for:
|
|
217
217
|
|
|
218
218
|
### Success Scenarios
|
|
219
|
+
|
|
219
220
|
- Valid requests with proper authentication
|
|
220
221
|
- Correct data formats and required fields
|
|
221
222
|
- Expected response structures
|
|
222
223
|
|
|
223
224
|
### Error Scenarios
|
|
225
|
+
|
|
224
226
|
- Missing or invalid authentication
|
|
225
227
|
- Validation errors (bad data formats)
|
|
226
228
|
- Missing required fields
|
|
@@ -229,6 +231,7 @@ The agent generates tests for:
|
|
|
229
231
|
- Conflict errors (409, duplicates)
|
|
230
232
|
|
|
231
233
|
### Edge Cases
|
|
234
|
+
|
|
232
235
|
- Empty request bodies
|
|
233
236
|
- Null/undefined values
|
|
234
237
|
- Boundary values (min/max lengths)
|
|
@@ -236,6 +239,7 @@ The agent generates tests for:
|
|
|
236
239
|
- Large payloads
|
|
237
240
|
|
|
238
241
|
### Performance
|
|
242
|
+
|
|
239
243
|
- Response time thresholds
|
|
240
244
|
- Payload size validation
|
|
241
245
|
- Concurrent request handling
|
package/agents/api-tester.md
CHANGED
|
@@ -10,6 +10,7 @@ You are a specialized API testing agent that automates endpoint testing with com
|
|
|
10
10
|
## Your Capabilities
|
|
11
11
|
|
|
12
12
|
### 1. REST API Testing
|
|
13
|
+
|
|
13
14
|
- **CRUD operations** - GET, POST, PUT, PATCH, DELETE
|
|
14
15
|
- **Request validation** - Headers, body, query parameters
|
|
15
16
|
- **Response validation** - Status codes, headers, body structure
|
|
@@ -17,6 +18,7 @@ You are a specialized API testing agent that automates endpoint testing with com
|
|
|
17
18
|
- **Error scenarios** - 4xx/5xx responses, invalid inputs
|
|
18
19
|
|
|
19
20
|
### 2. GraphQL Testing
|
|
21
|
+
|
|
20
22
|
- **Query testing** - Read operations with various selectors
|
|
21
23
|
- **Mutation testing** - Create, update, delete operations
|
|
22
24
|
- **Subscription testing** - Real-time data streams
|
|
@@ -24,12 +26,14 @@ You are a specialized API testing agent that automates endpoint testing with com
|
|
|
24
26
|
- **Schema validation** - Type checking, required fields
|
|
25
27
|
|
|
26
28
|
### 3. API Contract Testing
|
|
29
|
+
|
|
27
30
|
- **OpenAPI/Swagger** - Validate against spec
|
|
28
31
|
- **Schema validation** - JSON Schema, Joi, Yup
|
|
29
32
|
- **Breaking change detection** - Compare API versions
|
|
30
33
|
- **Documentation sync** - Ensure docs match implementation
|
|
31
34
|
|
|
32
35
|
### 4. Test Scenario Generation
|
|
36
|
+
|
|
33
37
|
- **Happy path tests** - Successful operations
|
|
34
38
|
- **Edge cases** - Boundary values, empty data
|
|
35
39
|
- **Error cases** - Invalid inputs, unauthorized access
|
|
@@ -39,6 +43,7 @@ You are a specialized API testing agent that automates endpoint testing with com
|
|
|
39
43
|
## When to Activate
|
|
40
44
|
|
|
41
45
|
Activate when the user needs to:
|
|
46
|
+
|
|
42
47
|
- Test REST or GraphQL API endpoints
|
|
43
48
|
- Validate API responses against schemas
|
|
44
49
|
- Generate API test suites
|
|
@@ -144,6 +149,7 @@ describe('API Endpoint: POST /api/users', () => {
|
|
|
144
149
|
## Validation Rules
|
|
145
150
|
|
|
146
151
|
Always validate:
|
|
152
|
+
|
|
147
153
|
- **Status codes** - Correct HTTP status
|
|
148
154
|
- **Response structure** - Expected JSON shape
|
|
149
155
|
- **Data types** - String, number, boolean, array, object
|
|
@@ -156,6 +162,7 @@ Always validate:
|
|
|
156
162
|
## Authentication Patterns
|
|
157
163
|
|
|
158
164
|
Handle common auth patterns:
|
|
165
|
+
|
|
159
166
|
- **Bearer tokens** - `Authorization: Bearer <token>`
|
|
160
167
|
- **API keys** - Header or query parameter
|
|
161
168
|
- **OAuth 2.0** - Token exchange flow
|
|
@@ -166,6 +173,7 @@ Handle common auth patterns:
|
|
|
166
173
|
## Tools and Libraries
|
|
167
174
|
|
|
168
175
|
Use appropriate tools for the language:
|
|
176
|
+
|
|
169
177
|
- **JavaScript/TypeScript**: axios, supertest, node-fetch
|
|
170
178
|
- **Python**: requests, httpx, pytest-httpx
|
|
171
179
|
- **Java**: RestAssured, OkHttp
|
|
@@ -175,6 +183,7 @@ Use appropriate tools for the language:
|
|
|
175
183
|
## Output Format
|
|
176
184
|
|
|
177
185
|
Provide:
|
|
186
|
+
|
|
178
187
|
1. **Complete test file** with all necessary imports
|
|
179
188
|
2. **Test data fixtures** or factories
|
|
180
189
|
3. **Authentication helpers** (if needed)
|
package/package.json
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: automating-api-testing
|
|
3
|
-
description:
|
|
4
|
-
|
|
5
|
-
Use when testing API contracts, validating OpenAPI specifications, or ensuring endpoint reliability.
|
|
6
|
-
Trigger with phrases like "test the API", "generate API tests", or "validate API contracts".
|
|
3
|
+
description: 'Test automate API endpoint testing including request generation, validation,
|
|
4
|
+
and comprehensive test coverage for REST and GraphQL APIs.
|
|
7
5
|
|
|
6
|
+
Use when testing API contracts, validating OpenAPI specifications, or ensuring endpoint
|
|
7
|
+
reliability.
|
|
8
|
+
|
|
9
|
+
Trigger with phrases like "test the API", "generate API tests", or "validate API
|
|
10
|
+
contracts".
|
|
11
|
+
|
|
12
|
+
'
|
|
8
13
|
allowed-tools: Read, Write, Edit, Grep, Glob, Bash(test:api-*)
|
|
9
14
|
version: 1.0.0
|
|
10
15
|
author: Jeremy Longshore <jeremy@intentsolutions.io>
|
|
11
16
|
license: MIT
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
tags:
|
|
18
|
+
- testing
|
|
19
|
+
- api
|
|
20
|
+
- graphql
|
|
21
|
+
compatibility: Designed for Claude Code, also compatible with Codex and OpenClaw
|
|
14
22
|
---
|
|
15
23
|
# API Test Automation
|
|
16
24
|
|
|
@@ -81,6 +89,7 @@ Automate comprehensive API endpoint testing for REST and GraphQL APIs including
|
|
|
81
89
|
## Examples
|
|
82
90
|
|
|
83
91
|
**Supertest REST API test suite:**
|
|
92
|
+
|
|
84
93
|
```typescript
|
|
85
94
|
import request from 'supertest';
|
|
86
95
|
import { app } from '../src/app';
|
|
@@ -126,6 +135,7 @@ describe('POST /api/products', () => {
|
|
|
126
135
|
```
|
|
127
136
|
|
|
128
137
|
**GraphQL API test:**
|
|
138
|
+
|
|
129
139
|
```typescript
|
|
130
140
|
it('fetches user by ID', async () => {
|
|
131
141
|
const query = `query { user(id: "1") { id name email } }`;
|
|
@@ -144,6 +154,6 @@ it('fetches user by ID', async () => {
|
|
|
144
154
|
- Supertest: https://github.com/ladjs/supertest
|
|
145
155
|
- REST-assured (Java): https://rest-assured.io/
|
|
146
156
|
- httpx (Python): https://www.python-httpx.org/
|
|
147
|
-
- Newman (Postman CLI):
|
|
157
|
+
- Newman (Postman CLI):
|
|
148
158
|
- OpenAPI specification: https://spec.openapis.org/oas/v3.1.0
|
|
149
|
-
- Ajv JSON Schema validator: https://ajv.js.org/
|
|
159
|
+
- Ajv JSON Schema validator: https://ajv.js.org/
|
|
@@ -5,16 +5,17 @@ Generates comprehensive test suites for REST and GraphQL APIs based on endpoint
|
|
|
5
5
|
Generated: 2025-12-10 03:48:17
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
import os
|
|
9
8
|
import json
|
|
10
9
|
import argparse
|
|
11
10
|
from pathlib import Path
|
|
12
11
|
from datetime import datetime
|
|
12
|
+
from typing import Dict
|
|
13
|
+
|
|
13
14
|
|
|
14
15
|
class Generator:
|
|
15
16
|
def __init__(self, config: Dict):
|
|
16
17
|
self.config = config
|
|
17
|
-
self.output_dir = Path(config.get(
|
|
18
|
+
self.output_dir = Path(config.get("output", "./output"))
|
|
18
19
|
self.output_dir.mkdir(parents=True, exist_ok=True)
|
|
19
20
|
|
|
20
21
|
def generate_markdown(self, title: str, content: str) -> Path:
|
|
@@ -25,7 +26,7 @@ class Generator:
|
|
|
25
26
|
md_content = f"""# {title}
|
|
26
27
|
|
|
27
28
|
Generated by api-test-automation
|
|
28
|
-
Date: {datetime.now().strftime(
|
|
29
|
+
Date: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
|
|
29
30
|
|
|
30
31
|
## Overview
|
|
31
32
|
{content}
|
|
@@ -56,10 +57,10 @@ api-test-automation
|
|
|
56
57
|
"category": "testing",
|
|
57
58
|
"plugin": "api-test-automation",
|
|
58
59
|
"data": data,
|
|
59
|
-
"config": self.config
|
|
60
|
+
"config": self.config,
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
with open(file_path,
|
|
63
|
+
with open(file_path, "w") as f:
|
|
63
64
|
json.dump(output_data, f, indent=2)
|
|
64
65
|
|
|
65
66
|
return file_path
|
|
@@ -71,7 +72,7 @@ api-test-automation
|
|
|
71
72
|
|
|
72
73
|
script_content = f"""#!/bin/bash
|
|
73
74
|
# Generated by api-test-automation
|
|
74
|
-
# Date: {datetime.now().strftime(
|
|
75
|
+
# Date: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
|
|
75
76
|
|
|
76
77
|
set -e # Exit on error
|
|
77
78
|
|
|
@@ -87,17 +88,20 @@ echo "✅ Completed successfully"
|
|
|
87
88
|
file_path.chmod(0o755) # Make executable
|
|
88
89
|
return file_path
|
|
89
90
|
|
|
91
|
+
|
|
90
92
|
def main():
|
|
91
|
-
parser = argparse.ArgumentParser(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
parser.add_argument(
|
|
95
|
-
parser.add_argument(
|
|
96
|
-
parser.add_argument(
|
|
93
|
+
parser = argparse.ArgumentParser(
|
|
94
|
+
description="Generates comprehensive test suites for REST and GraphQL APIs based on endpoint analysis and specifications."
|
|
95
|
+
)
|
|
96
|
+
parser.add_argument("--type", choices=["markdown", "json", "script"], default="markdown")
|
|
97
|
+
parser.add_argument("--output", "-o", default="./output", help="Output directory")
|
|
98
|
+
parser.add_argument("--config", "-c", help="Configuration file")
|
|
99
|
+
parser.add_argument("--title", default="api-test-automation Output")
|
|
100
|
+
parser.add_argument("--content", help="Content to include")
|
|
97
101
|
|
|
98
102
|
args = parser.parse_args()
|
|
99
103
|
|
|
100
|
-
config = {
|
|
104
|
+
config = {"output": args.output}
|
|
101
105
|
if args.config and Path(args.config).exists():
|
|
102
106
|
with open(args.config) as f:
|
|
103
107
|
config.update(json.load(f))
|
|
@@ -106,24 +110,20 @@ def main():
|
|
|
106
110
|
|
|
107
111
|
print(f"🔧 Generating {args.type} output...")
|
|
108
112
|
|
|
109
|
-
if args.type ==
|
|
110
|
-
output_file = generator.generate_markdown(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)
|
|
114
|
-
elif args.type == 'json':
|
|
115
|
-
output_file = generator.generate_json(
|
|
116
|
-
{"title": args.title, "content": args.content}
|
|
117
|
-
)
|
|
113
|
+
if args.type == "markdown":
|
|
114
|
+
output_file = generator.generate_markdown(args.title, args.content or "Generated content")
|
|
115
|
+
elif args.type == "json":
|
|
116
|
+
output_file = generator.generate_json({"title": args.title, "content": args.content})
|
|
118
117
|
else: # script
|
|
119
118
|
output_file = generator.generate_script(
|
|
120
|
-
args.title.lower().replace(
|
|
121
|
-
args.content or "# Add your script content here"
|
|
119
|
+
args.title.lower().replace(" ", "_"), args.content or "# Add your script content here"
|
|
122
120
|
)
|
|
123
121
|
|
|
124
122
|
print(f"✅ Generated: {output_file}")
|
|
125
123
|
return 0
|
|
126
124
|
|
|
125
|
+
|
|
127
126
|
if __name__ == "__main__":
|
|
128
127
|
import sys
|
|
128
|
+
|
|
129
129
|
sys.exit(main())
|