Bird
Raised Fist0
Cypresstesting~10 mins

Mochawesome reporter setup in Cypress - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Mochawesome reporter in Cypress configuration.

Cypress
const { defineConfig } = require('cypress');

module.exports = defineConfig({
  reporter: [1],
  e2e: {
    setupNodeEvents(on, config) {
      // implement node event listeners here
    }
  }
});
Drag options to blanks, or click blank then click option'
A'mochaawesome'
B'mochawesome'
C'mochawesomer'
D'mochawesome-reporter'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect reporter names like 'mochawesome-reporter' or misspelled versions.
2fill in blank
medium

Complete the code to add Mochawesome reporter options in Cypress configuration.

Cypress
module.exports = defineConfig({
  reporter: 'mochawesome',
  reporterOptions: {
    reportDir: [1],
    overwrite: false,
    html: true,
    json: true
  },
  e2e: {
    setupNodeEvents(on, config) {}
  }
});
Drag options to blanks, or click blank then click option'
A'cypress/reports/mochawesome-report'
B'cypress/reports/html'
C'mochawesome-report'
D'reports/mocha'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a path that does not exist or is not consistent with Cypress folder structure.
3fill in blank
hard

Fix the error in the reporter options to correctly disable HTML report generation.

Cypress
reporterOptions: {
  html: [1],
  json: true
}
Drag options to blanks, or click blank then click option'
A'false'
Bnull
C0
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'false' as a string instead of the boolean false.
4fill in blank
hard

Fill both blanks to correctly require and register Mochawesome in the Cypress plugins file.

Cypress
module.exports = (on, config) => {
  require([1])(on);
  return config;
};

// In cypress.config.js
setupNodeEvents(on, config) {
  return require([2])(on, config);
}
Drag options to blanks, or click blank then click option'
A'mochawesome/register'
B'cypress-mochawesome-reporter/plugin'
C'mochawesome/plugin'
D'mochawesome-reporter/register'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up plugin and register module names.
Using incorrect or non-existent module paths.
5fill in blank
hard

Fill all three blanks to configure Cypress to generate Mochawesome reports with screenshots and videos.

Cypress
module.exports = defineConfig({
  reporter: [1],
  reporterOptions: {
    reportDir: [2],
    overwrite: false,
    html: true,
    json: true
  },
  video: [3],
  e2e: {
    setupNodeEvents(on, config) {
      return require('cypress-mochawesome-reporter/plugin')(on);
    }
  }
});
Drag options to blanks, or click blank then click option'
A'mochawesome'
B'cypress/reports/mochawesome-report'
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Setting video to false disables recording screenshots and videos.
Using wrong paths for reportDir.

Practice

(1/5)
1. What is the main purpose of using the mochawesome reporter in Cypress testing?
easy
A. To create test data for Cypress tests
B. To speed up test execution time
C. To automatically fix failing tests
D. To generate clear and detailed HTML and JSON test reports

Solution

  1. Step 1: Understand the role of reporters in Cypress

    Reporters provide a way to view test results in a readable format after tests run.
  2. Step 2: Identify what mochawesome specifically does

    Mochawesome generates detailed HTML and JSON reports that are easy to read and share.
  3. Final Answer:

    To generate clear and detailed HTML and JSON test reports -> Option D
  4. Quick Check:

    Reporter purpose = Generate reports [OK]
Hint: Mochawesome = report generator, not test runner or fixer [OK]
Common Mistakes:
  • Thinking mochawesome speeds up tests
  • Confusing mochawesome with test data tools
  • Assuming mochawesome fixes test failures
2. Which of the following is the correct way to enable mochawesome reporter in cypress.config.js?
easy
A. reporter: 'mochawesome', reporterOptions: { reportDir: 'cypress/reports' }
B. reporter: 'mocha', reporterOptions: { output: 'cypress/reports' }
C. reporter: 'mochawesome', outputDir: 'cypress/reports'
D. reporter: 'mochawesome', reportPath: 'cypress/reports'

Solution

  1. Step 1: Recall the correct reporter property name

    The reporter is set using the key reporter with value 'mochawesome'.
  2. Step 2: Use the correct options key for mochawesome

    The options for mochawesome are passed under reporterOptions, including reportDir for output folder.
  3. Final Answer:

    reporter: 'mochawesome', reporterOptions: { reportDir: 'cypress/reports' } -> Option A
  4. Quick Check:

    Correct keys = reporter + reporterOptions [OK]
Hint: Use reporterOptions, not outputDir or reportPath [OK]
Common Mistakes:
  • Using 'mocha' instead of 'mochawesome'
  • Wrong option keys like outputDir or reportPath
  • Missing reporterOptions wrapper
3. Given this snippet in cypress.config.js:
reporter: 'mochawesome',
reporterOptions: {
  reportDir: 'cypress/reports',
  overwrite: false,
  html: false,
  json: true
}
What will be the result after running tests?
medium
A. HTML and JSON reports will be generated and overwritten each run
B. Only HTML reports will be generated and overwrite previous reports
C. Only JSON reports will be generated without overwriting previous ones
D. No reports will be generated because html is false

Solution

  1. Step 1: Analyze reporterOptions settings

    html is set to false, so no HTML report is generated. json is true, so JSON report is generated.
  2. Step 2: Understand overwrite behavior

    overwrite is false, so new reports will not overwrite existing ones, allowing multiple JSON reports to accumulate.
  3. Final Answer:

    Only JSON reports will be generated without overwriting previous ones -> Option C
  4. Quick Check:

    html=false + json=true + overwrite=false = JSON only, no overwrite [OK]
Hint: html false means no HTML report; overwrite false keeps old reports [OK]
Common Mistakes:
  • Assuming HTML report is generated when html=false
  • Thinking overwrite=false deletes old reports
  • Confusing json and html options
4. You configured mochawesome in cypress.config.js but after running tests, no report files appear. Which fix is most likely correct?
medium
A. Remove reporterOptions from config to fix issue
B. Install mochawesome and mochawesome-merge packages and update config
C. Change reporter to 'mocha' to generate reports
D. Run tests with --no-report flag to enable reports

Solution

  1. Step 1: Check if mochawesome packages are installed

    Mochawesome requires installing both mochawesome and mochawesome-merge packages to generate and merge reports.
  2. Step 2: Verify config and installation

    Without these packages installed, no reports will be created even if config is correct.
  3. Final Answer:

    Install mochawesome and mochawesome-merge packages and update config -> Option B
  4. Quick Check:

    Missing packages = no reports [OK]
Hint: Always install mochawesome and merge packages before running tests [OK]
Common Mistakes:
  • Removing reporterOptions thinking it fixes issue
  • Changing reporter to 'mocha' which doesn't generate mochawesome reports
  • Using wrong CLI flags like --no-report
5. You want to generate a single combined HTML report after running multiple Cypress test runs with mochawesome. Which approach is correct?
hard
A. Use mochawesome-merge to combine JSON reports, then generate HTML from merged JSON
B. Run tests with overwrite: true and html: true to auto-merge reports
C. Set reporter to 'mochawesome-merge' in cypress.config.js to merge reports automatically
D. Run tests multiple times with html: false and manually copy JSON files into one

Solution

  1. Step 1: Understand mochawesome report generation

    Mochawesome generates separate JSON reports per test run; it does not merge automatically.
  2. Step 2: Use mochawesome-merge tool

    mochawesome-merge combines multiple JSON reports into one, which can then be converted to a single HTML report.
  3. Step 3: Confirm other options are incorrect

    overwrite: true overwrites reports, no auto-merge; 'mochawesome-merge' is not a reporter; manual copying is error-prone.
  4. Final Answer:

    Use mochawesome-merge to combine JSON reports, then generate HTML from merged JSON -> Option A
  5. Quick Check:

    Merge JSON then generate HTML = combined report [OK]
Hint: Merge JSON reports first, then create one HTML report [OK]
Common Mistakes:
  • Expecting mochawesome to auto-merge reports
  • Setting reporter to 'mochawesome-merge' which is not valid
  • Manually copying JSON files without merging
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard