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

216
Vistas
Jest Unit Testing - how to unit test if/else condition and call method based on true/false inside jest?

I started learning Jest framework. Would like to write test case for following method

const valueCheck() =  () => {
if (typeof (props.user.value != undefined) && props.user.value){
    callResult([]);
} else{
   notification.warn(['Wrong value']);
 }
}

Not sure how to do that. Please help I am not able to figure this out

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

you need to test if callResult() or a notification.warn was called when you call valueCheck()

To do this you must use a spy function for valueCheck and notification

Also ,our syntax is incorrect and it can be simplified in a one line arrow function:

const valueCheck = () => props?.user?.value ? callResult() : notification.warn(['Wrong value'])
about 4 years ago · Santiago Gelvez 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