Skip to content
SDETRole
SDETRole

API Testing

API Assertion Builder

Generate Playwright, Postman, REST Assured or Cypress assertions.

Runs entirely in your browser No sign-up

Sample response

Fields · 0 of 0 selected

Fields from the response appear here. Arrays are listed once (for length checks) and walked through their first element.

Generated assertions

About this tool

Turning a sample response into assertions is mechanical work: walk the JSON, write one expectation per field, get the accessor syntax right for keys with dashes or dots, and use the right matcher for nulls and arrays. This builder lists every field in the response (arrays once, for a length check, and through their first element), lets you tick the ones that matter and generates code for Playwright (await expect(response).toBeOK() and expect(body.user.id).toBe(42)), Postman (pm.test with pm.expect), REST Assured (then().statusCode(200).body("user.id", equalTo(42))) and Cypress (cy.request with .its()). Choose exact values for stable fields or type-only checks for values that change between runs, such as ids and timestamps.

How to use it

  1. Paste a sample JSON response and set the method, URL and expected status.
  2. Tick the fields to assert. The first ten are selected by default; use All or None to change that quickly.
  3. Choose a framework and exact-value or type-only assertions, then copy the generated code into your test.

API Assertion Builder FAQ

Should I assert exact values or only types?

Assert exact values for fields your test controls or that are stable (status, role, currency). Use type-only checks for generated or time-dependent values (ids, timestamps, tokens), otherwise the test breaks on every run.

Why does REST Assured compare decimals as 12.5f?

By default REST Assured’s JsonPath returns decimals as Float, and Hamcrest’s equalTo(12.5) with a Double would not match a Float. If your project configures JsonPathConfig to return Double or BigDecimal, change the literal accordingly.

Why does the Cypress code add failOnStatusCode: false?

cy.request fails the test on 4xx and 5xx responses by default. When you expect an error status, the option lets the request complete so you can assert on the status and body.

Type to search across SDETRole.

Full-text search by Pagefind · runs in your browser Open search page →