Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
Is there a way to skip all tests in a suite if a certain conditions fail - JavaScript Jasmine?

Is there a way to skip all tests in a suite if a certain conditions fail? I.e) if the webpage is not opening, there is no point in running the rest of the tests, because they all depend on the webpage opening before any tests are run.

We can use pending() to skip the current test, but is there a way to skip all the tests in the suite or tests below right away if all the other tests depend on checkCondition to be true?

I tried adding pending() inside the beforeAll block, to try to skip all the tests since beforeAll is run before anything.

Please help! I am using WebdriverIO and Jasmine. Thank you!

let checkCondition = false;

describe(`My Test Suite`, () => {
  beforeAll(async () => {
     // EDIT - returnBoolean() is another method that logs into the 
     // page and returns true or false
     let setCheckCondition = returnBoolean();

    if (setCheckCondition) {
      checkCondition = true;
      console.log(`in true block`);
    } else {
      console.log('Skip tests below');  // HELP <-- since checkCondition is false, all tests below should fail 
      pending();
    }
  });

  it(`Test 1`, () => {
    if (checkCondition != undefined) {
      console.log("checkCOndition is defined")
    } else {
      pending();
    }
  });

  it(`Test 2`, () => {
    if (checkCondition) {
      // check 
    } else {
      console.log('Skip this test');
      pending();
    }
  });

  it(`Test 3`, () => {
    console.log("skip this test too")
  });

});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you have to set checkCondition in beforeAll and then eventually abort from there, there seems to be an ongoing issue about it on github (https://github.com/jasmine/jasmine/issues/1533)

Otherwise if checkConditon can be known before the test suite begins (I don't see why not) you can just just replace your beforeAll with something like

if (!checkCondition) return

Or just skip the whole call to describe in the first place

EDIT: You can skip the whole test suite like that:

let checkCondition = returnBoolean();
if (checkCondition) {
  describe(`My Test Suite`, () => {
    it(`Test 1`, () => {
      // run test 1 normally
    });
  
    it(`Test 2`, () => {
      // run test 2 normally
    });
  
    it(`Test 3`, () => {
      // run test 3 normally
    });
  
  });
} else {
  console.log("checkCondition is false. Skipping all tests!");
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!