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

164
Visualizações
Cypress doesn't take screenshots in CLI mode

I'm trying to take a simple screenshot using Cypress, however, it only works in the Cypress GUI (cypress open).
Whenever I run cypress run, it shows that the test succeeded but there's not screenshot saved.

This my code:

describe('Snapshot', () => 
    it.only('Take snapshot', async () => {
       cy.visit("http://www.google.com");
       cy.screenshot();
    });
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Actually, even in the GUI you may get inconsistent behaviour with the code you've provided: you should try to refactor your tests to avoid the use of async.

Cypress already does a lot of async stuff itself. See this answer for more information about how cypress uses promises, and avoiding async, as well as a few things you could try if you really want to use async.

Your code will successfully create screenshots under cypress run if you remove the axync keyword:

describe('Snapshot', () => {
    it.only('Take snapshot', () => {
       cy.visit("http://www.google.com");
       cy.screenshot();
    });
});

Note: I also added the missing opening brace { at the end of the first line. Since you say this code ran for you in the GUI, I'm assuming the brace was not the issue but was simply lost while posting.

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