← All features

Tests from responses

Turn responses into tests

Tests are written into the .http file as comments, so they travel with the requests and run wherever the requests do: in the app, in a Run tab, in a runbook or in your CI pipeline.

Every send runs the request's tests; the bar above the response sums them up.

Snapshots

Know exactly what changed

Press Snapshot and the response becomes the expected result. Every later send compares with it, value by value, so formatting and key order don't count, and a failure says precisely what moved.

  • Ignore what always changes with ignore $.updatedAt $.items[*].id.
  • Committed with the requests in a __snapshots__ folder, so reviews show the change.
A snapshot failure names the value that changed.

Written as comments

Four kinds of test, one file

Right-click a value in a JSON response to add an assertion for it, press Snapshot, or name an OpenAPI description at the top of the file. Other tools see plain comments.

  • Assertions on status, time, size, headers and any JSON path, with == != < > contains matches exists and more.
  • OpenAPI contract checks: the status must be documented and the body must fit the schema.
  • Script tests with client.test(), as in JetBrains IDEs.
  • In CI, reqjet run fails the build on a failed test and writes JUnit reports.
api/pets.http
# @reqjet.openapi ./openapi.yaml

### Get a pet
# @name pet
# @reqjet.assert status == 200
# @reqjet.assert body.$.name == "Rex"
# @reqjet.assert time < 500
# @reqjet.snapshot ignore $.updatedAt
GET {{baseUrl}}/pets/7

> {%
  client.test("Has a name", () =>
    client.assert(response.body.name));
%}
Reqjet logo

Try it on your own requests

Free for Windows, macOS and Linux, and it opens the .http files you already have.