Number of APIs: 1
GET https://postman-echo.com/get?foo1=bar1&foo2=bar2
This request demonstrates how to make assertions with Send the request to view the results of the sample tests in the The You can also use a second optional parameter with the The Using pm.response()
or pm.expect()
within the second parameter of the pm.test()
function.Test Results
tab in the response viewer.Working with the
pm.expect()
and pm.response()
functionspm.expect()
generic assertion function relies on Chai.js, a BDD / TDD assertion library for node.pm.test("Environment to be production", function () {
pm.expect(pm.environment.get("env")).to.equal("production");
});
pm.expect()
function to create a custom error message.pm.test("Using a custom error message", function () {
pm.expect(false, 'nooo why fail??').to.be.ok;
});
pm.response()
method uses pm.expect()
under the hood.pm.response()
as your base assertion allows you to receive more specific error messages when debugging. Here are some pm.response()
methods. Review the error messages under the Test Results
tab to see the difference.