Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda