Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

143
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda