# Postman tests: checking responses with pm.test, examples and running a collection

Source: https://checkcraft.ru/en/guides/postman-tests.html · updated 2026-11-24

How to write tests in Postman: the Scripts tab, pm.test and pm.expect, checking status, JSON fields, calculations and response time…

Practical workflow

Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. [Download, no sign-up →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

A Postman test is a script that runs after the response and checks it. Tests go on the Scripts tab, Post-response section, in JavaScript with the pm object. The most common mistake is checking only status 200: such a test stays green when the data is wrong. Below are checks that catch real bugs.

Checkcraft · 24 November 2026

Get help with your first test →

## Where to write tests

Open the request, the Scripts tab and the Post-response section. In older Postman versions this tab was called Tests. Snippets on the right insert templates such as a status check, but you must add your own fields and expectations.

## What to check besides status

Required fields, their types, allowed status values, calculations such as a discounted total, field relations and the absence of extra data like password hashes. A good trick: break the expected value and make sure the test goes red. If it does not, it checks nothing.

Moving off Postman? Checkcraft imports the collection and checks response values without JavaScript. [Download Free →](https://checkcraft.ru/en/download-checkcraft.html#free-download)

## Running in bulk

The Collection Runner runs all requests of a collection in order and shows failing tests. For CI use the Postman CLI or Newman. Note that the Postman free plan is now for a single user.

## Ready response tests

```
pm.test("статус 201", () => pm.response.to.have.status(201));

const order = pm.response.json();

pm.test("есть номер заказа", () => {
  pm.expect(order.id).to.be.a("number");
});

pm.test("итог = сумма позиций минус скидка", () => {
  const subtotal = order.items.reduce((s, i) => s + i.qty * i.price, 0);
  pm.expect(order.total).to.eql(subtotal - order.discount);
});

pm.test("статус из допустимого списка", () => {
  pm.expect(["NEW", "PAID", "SHIPPED", "CANCELLED"]).to.include(order.status);
});

pm.test("нет лишних полей с секретами", () => {
  pm.expect(order).to.not.have.property("passwordHash");
});

pm.test("ответ быстрее 800 мс", () => pm.expect(pm.response.responseTime).to.be.below(800));

// сохранить id для следующего запроса цепочки
pm.collectionVariables.set("orderId", order.id);
```

Each pm.test is reported separately, so a failure shows exactly what broke. The last line saves the order id for the next chained request: [request chains](https://checkcraft.ru/en/guides/api-request-chains.html).

## Weak vs strong checks

| Weak check | What it misses | Strong check |
|---|---|---|
| status 200 | Wrong data | status + fields + calculations |
| total exists | Wrong amount | total = items sum − discount |
| status not empty | Typo PAYED | status from the documented list |
| response not empty | Leaked passwordHash | no fields outside the contract |

If an AI wrote the tests, review them: they often only check that a response arrived. See [empty AI tests](https://checkcraft.ru/en/guides/ai-tests-empty-check.html).

## More on Postman

Section overview and all guides: [Postman requests: how to send GET, POST, PUT and DELETE with examples](https://checkcraft.ru/en/guides/postman-requests.html).

- [Postman variables: environments, collections and passing a token](https://checkcraft.ru/en/guides/postman-variables.html)
- [How to save a collection and a request in Postman: Save, History and a file](https://checkcraft.ru/en/guides/postman-save-collection.html)
- [How to import cURL into Postman: paste the command and get a ready request](https://checkcraft.ru/en/guides/postman-import-curl.html)
- [Postman errors 401, 403, 405 and 415: what they mean and how to fix them](https://checkcraft.ru/en/guides/postman-status-codes.html)
- [Postman collection audit: how many requests have no checks](https://checkcraft.ru/en/guides/postman-collection-audit.html)

Next step

## Repeat this on your own API

Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.

[Download Free](https://checkcraft.ru/en/download-checkcraft.html#free-download) · [Download and first run](https://checkcraft.ru/en/download-checkcraft.html)

No sign-up or email needed, the archive is ready in a couple of minutes. See the [edition limits](https://checkcraft.ru/en/pricing.html).

## References

[Postman: test scripts](https://learning.postman.com/docs/tests-and-scripts/write-scripts/test-scripts/)

## Continue with a related task

[Postman requests: how to send GET, POST, PUT and DELETE with examples](https://checkcraft.ru/en/guides/postman-requests.html) · [Postman collection audit: how many requests have no checks](https://checkcraft.ru/en/guides/postman-collection-audit.html) · [Validate API status codes, headers and response time](https://checkcraft.ru/en/guides/http-response-checks.html) · [API regression testing and response comparison](https://checkcraft.ru/en/guides/api-regression-testing.html) · [AI wrote the tests: 7 signs they check nothing](https://checkcraft.ru/en/guides/ai-tests-empty-check.html)

Start with the linked example and compare its result with your own test requirement.

Ask a person

## Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

[Ask in Telegram](https://t.me/checkcraftchat)Send an email

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

Page card: /ai/pages/en/guides/postman-tests.md
