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

245
Vistas
Writing list of tests in jest by defining list of inputs/expected outputs

I would like to write a set of tests in jest for the same function:

Lets say I have a function which adds numbers together

function add(a, b) {
  return a + b;
}

Now I would like to write a set of tests which check a set of inputs to this function e.g.

Test Name Inputs Expected Output
Positive Numbers {a:1,b:5} 6
First Negative {a: -1, b:5} 4
Second Negative {a:1, b:-5} -4
Both Negative {a: -1, b:-5} -6

Also I would ideally have multiple cases for each test e.g. for Positive Numbers

{{a:1, b:5, out: 6}, {a:4, b:7, out: 11}, {a:2, b:20, out:22}}

How could I go about doing this?

about 4 years ago · Santiago Trujillo
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