-
Notifications
You must be signed in to change notification settings - Fork 0
API Automation
yhAutomationQA edited this page May 16, 2026
·
1 revision
Reusable CRUD client at cypress/api/api-client.js that auto-logs every request/response.
| Method | Description |
|---|---|
get(path, options) |
GET request with query params |
post(path, body, options) |
POST with JSON body |
put(path, body, options) |
Full resource update |
patch(path, body, options) |
Partial resource update |
delete(path, options) |
Resource deletion |
send(method, path, options) |
Generic request (any HTTP method) |
All methods return Cypress chainables via cy.wrap(), supporting .then() chaining. Negative tests pass { failOnStatusCode: false } to handle 4xx/5xx responses without Cypress auto-failure.
{
headers: {}, // Additional headers
body: {}, // Request body (POST/PUT/PATCH)
qs: {}, // Query string parameters
failOnStatusCode: true // Set false for negative tests
}Chained assertion engine at cypress/api/response-validator.js:
ResponseValidator.from(response)
.status(200)
.bodyHasField("id")
.bodyFieldEquals("title", "expected")
.bodyIsArray()
.bodyArrayMinLength(1)
.headerExists("Content-Type")
.durationLessThan(3000);Zero-dependency JSON schema validator at cypress/api/schema-validator.js:
SchemaValidator.assertSchema(data, {
type: "object",
required: ["id", "title", "body"],
properties: {
id: { type: "integer", minimum: 1 },
title: { type: "string", minLength: 1 },
body: { type: "string" },
},
});Supported constraints: type, required, properties, items, minLength, maxLength, minimum, maximum, enum, pattern, additionalProperties.