0
0
Cypresstesting~10 mins

Mochawesome reporter setup in Cypress - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test verifies that the Mochawesome reporter is correctly set up in Cypress and generates a test report after running a simple test case.

Test Code - Cypress
Cypress
/// <reference types="cypress" />

// cypress.config.js
const { defineConfig } = require('cypress')

module.exports = defineConfig({
  reporter: 'mochawesome',
  reporterOptions: {
    reportDir: 'cypress/reports',
    overwrite: false,
    html: true,
    json: true
  },
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
    baseUrl: 'https://example.cypress.io'
  }
})

// cypress/e2e/sample_spec.cy.js

describe('Mochawesome Reporter Setup Test', () => {
  it('Visits the Kitchen Sink and checks title', () => {
    cy.visit('/')
    cy.title().should('include', 'Kitchen Sink')
  })
})
Execution Trace - 4 Steps
StepActionSystem StateAssertionResult
1Test startsCypress test runner initializes with Mochawesome reporter configured-PASS
2Browser opens and navigates to baseUrl 'https://example.cypress.io'Browser displays the Kitchen Sink page-PASS
3Finds the page title elementPage title is visible and contains textcy.title().should('include', 'Kitchen Sink') verifies page title includes 'Kitchen Sink'PASS
4Test completes and Mochawesome reporter generates HTML and JSON reports in 'cypress/reports'Report files are created and savedReport files exist and contain test resultsPASS
Failure Scenario
Failing Condition: Mochawesome reporter is not configured correctly or report directory is missing permissions
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about the page title?
AIt includes the text 'Kitchen Sink'
BIt exactly matches 'Example Domain'
CIt is empty
DIt contains the word 'Cypress'
Key Result
Always verify your test reporter configuration and ensure the report output directory exists with proper permissions to generate test reports successfully.