API & testing

Tests and collection runs

Response checks, scripts and repeatable request workflows.

Scripts and checks

A pre-request script prepares data before sending. A post-response script checks the result and can save values for subsequent steps. Scripts can be defined on collections, folders and requests.

Add checks in the interface or write them in JavaScript. Results show which conditions passed or failed.

pm.test("Order loaded", () => {
  pm.response.to.have.status(200);
  const order = pm.response.json();
  pm.expect(order.items.length).to.be.above(0);
});

Running a collection

  1. Open the collection runner from the API tree.
  2. Select requests and their execution order.
  3. Choose an environment, iteration count and an optional CSV or JSON data file.
  4. Start the run and follow request progress.
  5. Review final statuses, checks and errors.
Run configuration and summary: 8 requests and 24 assertions passed.

Comparing responses

Snapshots preserve a reference response for comparison with later results. Configure ignored JSONPath paths for fields that change on every run, such as timestamps or request identifiers.