pm.test('Status code is 200 or 201', function () { pm.expect(pm.response.code).to.be.oneOf([200, 201]); });
The test expects the response code to be either 200 or 201. Since 404 is not in this list, the assertion fails and the test fails.
Option A correctly checks that the 'success' property is of boolean type. Option A wrongly compares to string 'true'. Option A is invalid syntax. Option A uses incorrect assertion syntax.
Tests that do not run due to conditions are skipped. The overall test result depends on the tests that do run. Postman does not fail or error automatically if no condition matches.
pm.test('Check status', () => { if (pm.response.code === 200) { pm.expect(true).to.be.true; } else if (pm.response.code === 404) { pm.expect(true).to.be.true; } });
If the response code is not 200 or 404, no assertion runs inside the test callback. Postman treats this as a failed test because no assertion was made.
Option B uses a switch with a default case that explicitly fails the test if the response code is unexpected. Options B, C, and D do not fail the test for unexpected codes properly.