@api-core/verify
v0.0.2
Published
Framework-agnostic API verification DSL and contract validation for API-CORE
Maintainers
Readme
@api-core/verify
Framework-agnostic API verification DSL and contract validation for API-Core. It provides expressive assert methods to validate HTTP responses, status codes, headers, cookies, and schemas.
Installation
npm install @api-core/verify @api-coreQuick Start
import { verify } from '@api-core/verify';
// Inside a test
const response = await client.get('comment.getComment', { path: { id: 5 } });
verify(response)
.toBeSuccessful()
.toHaveHeader('content-type', /json/)
.toHaveStatus(200);Features
- Expressive Assertions: Verify status codes (
toHaveStatus,toBeSuccessful), headers (toHaveHeader), and cookies. - Deep Object & Schema Validation: Validate response body schemas and objects with strict deep-equality matching.
- Custom Verifiers: Extend the assertion chain with asynchronous custom verifiers.
Example
For details on verify suite capabilities, see examples/src/tests/verify.test.ts or packages/verify/tests/verify.test.ts.
API Overview
verify(response)
Initiates the assertion chain. Supported assertions:
toHaveStatus(code)/toHaveStatusIn(codes[])toBeSuccessful()/toBeFailure()toHaveHeader(name, valueOrRegex)toHaveBody(expectedBody)toContainBody(partialBody)custom(callback)(Async custom assertion)
License
MIT © Shanmuka Chandra Teja Anem
Contributing
Contributions are welcome! Please read the root contributing guidelines, open an issue, or submit a pull request.
