In the [[|previous tutorial], we saw how to write a simple test for the returned status code of a real world API. However, testing only the returned status code is not enough. For the previously created request, we need to check for example that the board that we want to create has been actually created with the proper name and specific settings.
pm.test("Your test name", function () { var jsonData = pm.response.json(); pm.expect(jsonData.value).to.eql(100); });
pm.test("Board shoud be created", function () { var jsonData = pm.response.json(); pm.expect(jsonData.name).to.eql("My API board"); });
pm.test("Board shoud be created", function () { var jsonData = pm.response.json(); pm.expect(jsonData.name).to.eql("My API board"); pm.expect(jsonData.closed).to.eql(false); });
pm.test("Board shoud be private", function () { var jsonData = pm.response.json(); pm.expect(jsonData.prefs.permissionLevel).to.eql("private"); });