k6-example-api-contract-validation

Stars
5
Committers
2

k6 API contract validation example

This is a complete example of API contract validation in k6 using the expect library.

Contracts are stored in ./api_contracts folder as .js files. Contracts can also be standard .json files if there's no need to compose complex contracts from multiple objects.

Contract format

API contracts follow the JSON Schema format. Under the hood, the expect library is using Ajv JSON schema validator developed by Mozilla.

About this example

The example script validates API contracts of selected services from https://test-api.k6.io/.

Screenshots

k6 run k6-API-contract-validation-example.js k6 CLI

k6 cloud k6-API-contract-validation-example.js k6 cloud