0.3.4 • Published 5 years ago

mocha-munit-reporter v0.3.4

Weekly downloads
120
License
MIT
Repository
-
Last release
5 years ago

Munit - mocha js reporter for nested suites

Basically as JUnit doesn't allow you to generate a nice report that has nested sections/describes, we created this report format.

Usage

mocha test --reporter=mocha-munit-reporter --reporter-options name="Acceptance Test" xmlfile="report.xml"

You can pass any of the below options to get the desired result from the reporter.

reporterOptions:

  • name: of the report (string)
  • xmlPrettyPrint: whether or not we generate a xml file with new lines (bool)
  • runXml: whether or not to generate xml (bool)
  • spec: whether or not to output the tests as they run (bool)
  • xmlfile: path that the xml file is written to (string)
  • skipTimeout: so if a test takes less than this time e.g. if a test takes 0.0001 and our timeout is 0.001 then we mark it as skipped, useful for manual test cases (float/number)
  • parseComments: so if we want to parse the body of a test for comments with steps,notes, etc. in or not (boolean)

Typical use cases:

  • you want to have case steps and nested sections: you can leave it at the default config
  • you want just the nested sections: set skipTimeout = 0 and parseComments = false (as setting skipTimeout to 0 will disable skipped based on duration)

tests

test coverage is for generating the tree and xml validation npm test

Please add or update tests when changing the reporter!

xml spec

This is similar other formats but just allows more details for each case.

<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="sections" >
        <xs:complexType>
            <xs:complexContent>
                <xs:extension base="sectionType">
                    <xs:attribute type="xs:string" name="timestamp" use="required"/>
                </xs:extension>
            </xs:complexContent>
        </xs:complexType>
    </xs:element>
    
    <xs:complexType name = "caseType">
        <xs:sequence maxOccurs="unbounded">
            <xs:element name = "failure" type = "xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name = "note" type = "xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name = "step" type = "xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name = "expected" type = "xs:string" minOccurs="0" maxOccurs="1"/>
            <xs:element name = "actual" type = "xs:string" minOccurs="0" maxOccurs="1"/>
        </xs:sequence>
        <xs:attribute type="xs:string" name="name"/>
        <xs:attribute type="xs:short" name="tests"/>
        <xs:attribute type="xs:int" name="failures"/>
        <xs:attribute type="xs:boolean" name="skipped"/>
        <xs:attribute type="xs:double" name="time"/>
    </xs:complexType>

    <xs:complexType name = "sectionType">
        <xs:sequence>
            <xs:element name="case" type="caseType" maxOccurs="unbounded" minOccurs="0"></xs:element>
            <xs:element name="section" type="sectionType" maxOccurs="unbounded" minOccurs="0"></xs:element>
        </xs:sequence>
        <xs:attribute type="xs:string" name="name" use="required"/>
        <xs:attribute type="xs:int" name="tests" use="required"/>
        <xs:attribute type="xs:int" name="failures" use="required"/>
        <xs:attribute type="xs:int" name="skipped" use="required"/>
        <xs:attribute type="xs:double" name="time" use="required"/>
    </xs:complexType>
    
</xs:schema>

MIT License

Copyright (c) 2018

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.2

6 years ago

0.0.1

6 years ago