DEV Community

John Peters
John Peters

Posted on

Cypress Test Logging in 20 minutes

First Things First

  • If you want to view test run results, you must use the right Cypress command.
// this method doesn't write output to the files
npx cypress open

// this method does write output
npx cypress run
Enter fullscreen mode Exit fullscreen mode
  • The results are only written when the test fails.

Mochawesome Test Result

Alt Text

This format is acceptable, let's see how we integrated Mocha Awesome into our Cypress Tests.

  • npm install mochawesome --save-dev
  • Change cypress.json in root directory
{
    // the approot cypress.json file
    "baseUrl" :"https://localhost/home",
    "reporter": "mochawesome", 
    "reporterOptions": {
        "reportDir": "cypress/reports/mochawesome-report",
        "reportFilename": "sample",
        "overwrite": false,
        "html": true,
        "json": true  
     }
}
Enter fullscreen mode Exit fullscreen mode

Add this into the Cypress/Support/index.js file.

// The Cypress/Support/index.js file
import './commands'
import  'cypress-mochawesome-reporter/register'
Enter fullscreen mode Exit fullscreen mode
  • Start the test run
npx cypress run
Enter fullscreen mode Exit fullscreen mode

Console Output

As your tests run you will see output going to the console of your IDE terminal. But only failed tests write the reports, screenshots and mp4.

Test Completion

Alt Text

Total set up time: 20 minutes.

JWP2020

Oldest comments (0)