My question:
I want to test whether or not the request I’m sending:
- returns a status code 400
- contains the desired error message in the return body
I am looking for a solution for 2).
Details (like screenshots):
- is easily solved, but I cannot find a solution to validate point 2.
I’ve already tried:
pm.test(“Body contains string”,() => {
pm.expect(pm.response.text()).to.include(‘“The chosen growth model depends on the field "unit dimension - area" of the unit to be filled.”’);
})
pm.test(“Body is correct”, function () {
pm.response.to.have.body(‘{“errors”:{“unit”:[{“code”:“productiongroup.unitGrowthModelDependsOnUnitArea”,“message”:“The chosen growth model depends on the field "unit dimension - area" of the unit to be filled.”}]},“type”:“RFC 7231 - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content Request”,“status”:400,“traceId”:“00-8dc5cb52d7a586e6e908ca43857dadaa-da58410cb7341006-00”}’);
});