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

298
Visualizações
Cypress - How to get data of individual test like its title, state etc

I am trying to get data about single test in Cypress like title, state etc so I can create custom reporter. But none of the below options in forEach are working. It returns undefined, but when I pass normal string like 'abcd' it gets printed on console. So how do i get attributes of the test.

first.spec.js

/// <reference types="cypress" />
  context('Actions', () => {
  
  afterEach(()=> {
    const testData = cy.state('runnable').currentTest;
      cy.task('testOutput', {title: testData.title, state: testData.state, fullTitle: testData.fullTitle()});

     // also tried 

   // Cypress.on('test:after:run', (test, runnable)=> {
    //cy.task('testOutput', {title: runnable.title, state:runnable.state, fullTitle: runnable.fullTitle()});
   //)};
  });

  it('test 1',()=>{
   
    const assets = Cypress.env('assetoverride');
    cy.getVar(assets);
  })
});

plugin/index.js

module.exports = (on, config) => {
  on('task', {
    testOutput({title, state, fullTitle}){
      console.log(`Test ${fullTitle} - ${state} - ${title}`)
      return null;
    }
  });
}
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

If you are executing your tests localy you can run them in hedless mode by running command:

npx cypress run --spec "e2e/integration/NameOfYourTestFile.spec.js" --browser chrome --headless

This way you will get table with results in the terminal: enter image description here

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