Older style of writing Qodex tests (deprecated)

GET https://postman-echo.com/get

This section refers to deprecated script syntax used in older versions of Qodex. If you are writing scripts now, please use the newer syntax.

The older style of writing Qodex tests relies on setting values for the tests object. You can set a descriptive key for an element in the object and then assert if it's true or false. For example, the following will check whether the response body contains the user_id string:

tests["Body contains user_id"] = responsebody.has("user_id");

You can add as many keys as needed, depending on how many things you want to test for. You can view your test results in the response viewer under the Tests tab. The tab header shows how many tests passed, and the keys that you set in the tests variable are listed there. If the value evaluates to true, the test passed.