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

229
Vistas
Running jest tests in parallel based on a list of parameters

In my case I have a test file containing a few hundred tests using jest

describe('my test-suite', () => {
   test('test 1', () => {
       expect(1).toBe(1);
   });
   //another hundred tests...
});

What I need to do now is to run these tests for different parameters, specified on a config file. More in details in my case the config file specifies some external parameters for external services (think like DB access parameters) and ideally I would like to keep exactly the same structure I already have, running the same tests multiple times against all these external services.

Ideally I should be able to do something like:

const paramList = [{
    name: 'service 1'
}, {
    name: 'service 2'
}];

describe('my parallel test-suite', () => {
    it.each(paramList)("testing against $name", ({name}) => {

        //just what I had before
        describe('my test-suite', () => {
           test('test 1', () => {
               expect(1).toBe(1);
           });
           //another hundred tests...
        });

    });
});

Ideally the next step would be to replace the test.each with test.concurrent.each and being able to run my tests in parallel against all the different external services.

Unfortunately with the code (and Jest version 27.4.7) above what I get is:

Cannot nest a describe inside a test. Describe block "my test-suite" cannot run because it is nested within "service service 1".

Tests cannot be nested. Test "test 1" cannot run because it is nested within "service service 1".

Is there a way to achieve what I'm trying to do here?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can't run a describe block in an each loop. Run each test in its own loop and then it will work. Something like this:

describe('my parallel test-suite', () => {
    it.each(paramList)("testing against $name", ({name}) => {
        expect(1).toBe(1);
    });
    it.each(paramList)("another test against $name", ({name}) => {
        expect(2).toBe(2);
    });
    //another hundred 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