cypress-mochawesome-csv-united-report

1.3.2 • Public • Published

Cypress Mochawesome CSV United Report

Cypress Mochawesome CSV United Report is a command-line tool that merges all Cypress Mochawesome JSON reports into a customized CSV file. The reports should be located in the cypress/reports folder within a Cypress project.

Features

  • Merges multiple JSON files into one CSV report.
  • Automatically handles file naming conflicts for CSV output.
  • Extracts relevant data from Mochawesome reports (time, suite, test case, pass/fail status, etc.).
  • Customizable delimiter for CSV formatting.

Prerequisites

  • Node.js version 14.0.0 or higher.
  • Typescript setup in your project (if you're modifying the source code).

Installation

To install the package locally, run the following command in your Cypress project root:

npm install cypress-mochawesome-csv-united-report

Usage

  • Once installed, you can generate a CSV report by running the following command:
npx csv_report

Command Breakdown

  • csv_report: This will merge all the JSON files located in the cypress/reports directory and create a CSV report.

Custom CSV File Location

  • By default, the merged CSV file will be saved to cypress/reports/csv_report.csv. If a file with that name already exists, a new file with a unique name (e.g., csv_report+1.csv, csv_report+2.csv, etc.) will be created automatically.

Example

Assuming your cypress/reports directory contains the following Mochawesome JSON files:

  • cypress/reports/test-results-1.json
  • cypress/reports/test-results-2.json

Running npx csv_report will generate a CSV file at:

  • cypress/reports/csv_report.csv

  • The CSV file will include data from both JSON files, containing fields such as:

    • Day: Day of the test report.
    • Time: Timestamp of the test report.
    • suite: Test suite name.
    • Test Case: Individual test case name.
    • Duration: Duration of the test.
    • Speed: Speed of the test execution.
    • State: Test state (passed, failed, pending).
    • Context: Additional context, if available.
    • Code: Test code snippet, if provided.
    • error: Error details, if any.

CSV Formatting

  • The default delimiter used in the CSV file is the Star Symbol (*) . You can modify this by adjusting the source code.
  • The generated CSV will escape the delimiter and any newlines in the fields to ensure proper formatting.

If You have Errors while Installing or Running:**

Such as: The error message indicates that Node.js cannot find the cli.js file for the cypress-mochawesome-csv-united-report command. This could be due to a couple of reasons:

  • Incorrect Caching: Sometimes, npm might cache incorrectly. Try clearing the npm cache:

    npm cache clean --force

    Then, reinstall the package:

    npm install cypress-mochawesome-csv-united-report
  • Global vs. Local Installation: If you installed cypress-mochawesome-csv-united-report globally (using -g flag), but, using local installations within your project directory is generally recommended.

2. Running cypress-mochawesome-csv-united-report:

The package.json already defines a script named cypress-mochawesome-csv-united-report that should run the report generation functionality. You can use this instead of the full command:

npx csv_report

Additional Tips:

  • Check File Paths: Double-check the paths in your package.json to ensure they are accurate relative to your project structure.
  • Project Setup: Verify that you've run npm install after adding cypress-mochawesome-csv-united-report as a dependency to include it in your project's node_modules folder.

By following these steps and considering the alternative approaches for running the reporter, you should be able to successfully generate reports using cypress-mochawesome-csv-united-report.

License

  • This project is licensed under the Apache-2.0 License. See the LICENSE file for more details.

Author

  • Mohamed Said Ibrahim

Package Sidebar

Install

npm i cypress-mochawesome-csv-united-report

Weekly Downloads

0

Version

1.3.2

License

Apache-2.0

Unpacked Size

36.8 kB

Total Files

9

Last publish

Collaborators

  • mohamed_said_ibrahim