1.0.4 • Published 5 months ago

mochawesome-converter v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Test report files to Mochawesome and JUnit converter

Actions Status Codacy Badge Git Issues Closed Issues

Overview

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

Supported report formats

  • JUnit/xUnit 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 are first converted to JUnit format using XSLT.
  • Any nested test suites are flattened.
  • 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.
  • Tests suites without any tests are excluded from Mochawesome and JUnit.
  • Attachments are not supported.

JUnit

  • Converts <properties>, <system-out> and <system-err> elements to Mochawesome test context.

NUnit

  • NUnit v3+ XML is supported.
  • Converts <properties> elements to JUnit <properties>.
  • Converts <output> elements to JUnit <system-out>.

xUnit.net

  • xUnit.net v2+ XML is supported.
  • Converts <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>.
  • Converts Inconclusive and NotExecuted tests to <skipped> with message.
  • 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 --save-dev mochawesome-converter
const convert = require('mochawesome-converter');

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

convert(options).then(() => console.log(`Mochawesome report created`));

Options

OptionTypeDefaultDescription
testFile (required)stringPath to test file for conversion
testType (required)stringTest report type
reportDirstring./reportConverted report output path
reportFilenamestringtestFile.name-mochawesome.jsonMochawesome report name
junitbooleanfalseCreate JUnit report?
junitReportFilenamestringtestFile.name-junit.xmlJUnit report file name
htmlbooleanfalseCreate Mochawesome HTML?
htmlReportFilenamestringtestFile.name-mochawesome.htmlMochawesome HTML file name
skippedAsPendingbooleantrueShow skipped tests as pending in Mochawesome
switchClassnameAndNamebooleanfalseSwitch 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 if your test naming data is generated in reverse order.

Supported testType options.

testTypeFile Type
JUnitJUnit/xUnit
NUnitNUnit 3+ XML
xUnitxUnit.net v2+ XML
TRXVisual Studio TRX
1.0.4

5 months ago

1.0.3

7 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago