Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!