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

142
Vistas
How to test a simple method that returns void in Cypress?

I have the following function that I'd like to test with Cypress:

let stopped = false; // global variable

export const = stopDoingStuff = () => {
 stopped = true;
}

I want to test if the methods sets the variable stopped to true, after calling it.

This is my current state. I don't know how the check the global variable after calling the function...

it('should set stopped to true', async () => {
  let stopped = false;
  stopDoingStuff();
  expect(stopped).to.equal(true);
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's always better to also mention what the result of your code is.

But I can see that variable stopDoingStuff is exported, so I assume the whole piece of code is in a separate module. Since stopped variable is not exported, you can't access it from anywhere but the module it's in.

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