Bypass or skip tests for a request

Is there a way to exit a set of tests for a given request early. So in the example below, cut down and simplified, if I don’t get a Person object returned then I’d like to exit at that point. I know I can use a “throw new Error()” but if I do then I can’t see the results of the earlier tests.


  "Person": [
      "PersonIdentifiers": {
        "Identifier": [
            "IdentifierType": "PID",
            "IdentifierValue": "123456"
      "PersonNames": {
        "FirstName": "James"


pm.test("Status code is 200", function () {;

if (pm.response.code === 200) {
	var jsonData = pm.response.json();

	pm.test("Has a Person", function () {
// **Exit Here**
	var personObj = jsonData.Person[0];
	pm.test("Has an Identifier", function () {
// **Or Exit Here**
	var identifierObj = personObj.PersonIdentifiers.Identifier[0];

	pm.test("Check IdentifierType", function () {
// **Etc.**
	pm.test("Check IdentifierValue", function () {

Wherever you want to ‘Exit’ you can just use the ‘return’ command.
Mind you, if you use ‘return’ inside a function, it just returns out of the function.

I’ve used it at the script level with no problems.

There might be a better way. If so, wait on for further replies on this thread… I’ll be curious as well.

@TimArmstrong There’s no special way to do so in the app, but javascript gives you a lot of power in the scripts.

A few things you might be able to do are:

  1. You can wrap your tests in an if statement.
  2. Make your tests nested. You can import this collection example in your app and see:
  3. Write early bail-out conditions as you already mentioned like using throw or return in the script itself.

In addition to the above response, there’s also another way to directly control the skipping of the complete tests using some control boolean.

You can either use an environment variable or you can perform the computation in the test script whether you want to set a test (or a set of tests) and use that.

For eg:

let skipTest = pm.environment.get('skipTest');

(skipTest ? pm.test.skip : pm.test)("Check status code", () => {

(skipTest ? pm.test.skip : pm.test)("Check status code is not 404", () => {