Skip to main content

Assertions

PrismAssertResponse wraps an HTTP response with chainable assertion methods. Instead of manually checking status codes, headers, and body content, chain assertions for readable, expressive tests.

Quick Start

Chainable Assertions

Available Assertions

Status Code

Assert Status

Headers

Assert Headers

Body Content

Assert Body

JSON Decoding

Assert and Decode JSON

Chaining

Every assertion returns self, so you can chain multiple checks:
Chain Everything

Reading the Body

Body Access

Complete Test Example

Full Test Suite

Error Types

Test Errors
Use assertJSON at the end of your chain — it returns the decoded value, not PrismAssertResponse, so you can’t chain more assertions after it. Put status and header checks first.
Assertions use Swift’s assert(), which is removed in release builds. For tests (which always run in debug mode), this is fine. If you need assertions in release builds, use precondition() or Swift Testing’s #expect.