npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mochawesome-converter

v1.0.2

Published

Test report files to Mochawesome and JUnit converter

Downloads

106

Readme

Test report files to Mochawesome and JUnit converter

Overview

  • Convert your XML/TRX test report files to Mochawesome for easy viewing and troubleshooting.
  • Convert test report files to JUnit format.

Supported report formats

  • JUnit XML Format
  • NUnit 3.0+ XML Format
  • xUnit.net v2+ XML Format
  • Visual Studio TRX Format

What is Mochawesome

Mochawesome is a custom test reporter originally designed for Mocha Javascript testing framework. It features a clean modern interface allowing users to easily view and navigate test runs.
https://github.com/adamgruber/mochawesome

List of supported features

  • Simple, clean, and modern design
  • Per suite charts (via ChartJS)
  • Stack trace for failed tests
  • Support for displaying context information
  • Filters to display only the tests you want
  • Responsive and mobile-friendly
  • Offline viewing

Features not supported by converter

  • Support for test and suite nesting
  • Displays before and after hooks
  • Review test code inline

Conversion process

  • All test reports except JUnit are first converted to JUnit format using XSLT.
  • TRX files undergo additional processing to enhance JUnit output.
  • Set junit option to true to get JUnit conversion results.

All test types

  • Converts <skipped> test messages to Mochawesome test context values.
  • Converts <properties>, <system-out> and <system-err> to Mochawesome context values.
  • Converts <failure> and <error> elements to Mochawesome error stack.
  • Test suites are displayed in alphabetical order by file and classname attributes.
  • Tests suites without any tests are excluded from Mochawesome and JUnit.
  • Attachments are not supported.

JUnit

  • Converts testcase <properties>, <system-out> and <system-err> elements to Mochawesome test context.
  • Nested test suites currently not supported.

NUnit

  • NUnit XML version 3 and higher is supported.
  • Converts test-case <properties> elements to JUnit <properties>.
  • Converts test-case <output> elements to JUnit <system-out>.
  • Nested test-suite elements are flattened and appear in classname order.

xUnit

  • xUnit.net v2+ XML is supported.
  • Converts test <traits> elements to to JUnit <properties>.
  • Converts test <reason> elements to JUnit <skipped>.
  • Supports single <assembly> per file, if multiple assemblies are present only first will be converted.

Visual Studio TRX

  • Converts Output/ErrorInfo/Message to JUnit <failure> message.
  • Converts Output/ErrorInfo/StackTrace to JUnit <failure> stack trace.
  • Converts Output/StdErr to JUnit <system-err>.
  • Converts Output/StdOut to JUnit <system-out>.
  • Test suites are split into multiple <testsuite> elements by test classname.
  • Tests are ordered by name.
  • Test suit times are not 100% accurate - displayed as a sum() of all test times.

Usage

npm i mochawesome-converter
const convert = require('mochawesome-converter');

let options = {
    testFile: 'mytesfiles/nunit.xml',
    testType: 'nunit',
    junit: true
}

convert(options).then(() => console.log(`Report created: ${options.reportDir}/${options.reportFilename}`));

Options

| Option | Type | Default | Description | |:--------------------------|:--------|:--------------------------|:--------------------------------------| | testFile (required) | string | | Path to test file for conversion | | testType (required) | string | | Test report type | | reportDir | string | ./report | Converted report output path | | reportFilename | string | mochawesome.json | Mochawesome report name | | junit | boolean | false | Create JUnit report? | | junitReportFilename | string | testFile.name-junit.xml | JUnit report file name | | html | boolean | false | Create Mochawesome HTML? | | htmlReportFilename | string | mochawesome.html | Mochawesome HTML file name | | skippedAsPending | boolean | true | Show skipped tests as pending in HTML | | switchClassnameAndName | boolean | false | Switch test case classname and name |

  • testFile - relative or absolute path to input test file.
  • testType - type of test report, not case-sensitive.
  • reportDir - will be created if path does not exist.
  • skippedAsPending - Mocha always reports skipped tests as pending and this is default behaviour of converter. Set to false to display tests as skipped.
  • switchClassnameAndName - Switches classname and name attributes of testcase in case your test naming data is generated in reverse order.

Supported testType options.

| testType | File Type | |:-----------|:------------------| | JUnit | JUnit | | NUnit | NUnit 3.0+ XML | | xUnit | xUnit.net v2+ XML | | TRX | Visual Studio TRX |