Builds the AI prompt for generating Playwright API tests from captured HAR endpoint summaries.
Unlike UI tests (which use page.click(), page.fill()), API tests use
Playwright's request API context (apiRequestContext) to make HTTP calls
directly and assert on status codes, response shapes, and headers.
Exports
formatJsonExample—(raw, maxChars?) → stringbuildApiTestPrompt—(endpoints, appUrl) → { system, user }
- Source:
Methods
(static) buildApiTestPrompt(endpoints, appUrl, optsopt) → {Object}
Build the system + user prompt for API test generation.
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
endpoints |
Array.<ApiEndpoint> | — from summariseApiEndpoints() |
|||||||||
appUrl |
string | — project base URL |
|||||||||
opts |
object |
<optional> |
Properties
|
- Source:
Returns:
- Type
- Object
(static) formatJsonExample(raw, maxCharsopt) → {string}
Truncate a JSON request/response body example to fit within a token budget.
For JSON arrays, incrementally includes elements until maxChars is reached.
For JSON objects, incrementally includes keys. Always preserves at least one
element/key so the shape is visible. Non-JSON payloads are sliced with a
[truncated] marker.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
raw |
string | * | — raw body string (or falsy/non-string passthrough) |
||
maxChars |
number |
<optional> |
1800 | — approximate character budget |
- Source:
Returns:
Truncated JSON or sliced string
- Type
- string