junit-xml
JUnit XML report builder with TypeScript support.
Installation
npm install junit-xml
Usage
; const testSuiteReport = name: 'Some test suite report name' time: 42 suites: name: 'Some suite' timestamp: Date hostname: 'some-hostname' time: 11337 testCases: name: 'Successful test' assertions: 2 classname: 'successful-test-class' time: 072 name: 'Skipped test' assertions: 2 skipped: true name: 'Unskipped test' skipped: false name: 'Failing test' failures: message: 'First failure' type: 'some-type' message: 'Second failure' name: 'Another failing test' failures: message: 'Just one failure' name: 'Erroring test' errors: message: 'First error' type: 'some-type' message: 'Second error' name: 'Another erroring test' errors: message: 'Just one error' name: 'Test with output' systemOut: 'First output' 'Second output' name: 'Test with single output' systemOut: 'Only output' name: 'Test with error output' systemErr: 'First error output' 'Second error output' name: 'Test with single error output' systemErr: 'Only error output' name: 'Suite without test cases' testCases: name: 'Another suite' testCases: name: 'Some successful test' ; const junitXml = ;
API
getJunitXml(testSuiteReport: TestSuiteReport, options?: { schema: 'default' | 'ant-junit' }): string
testSuiteReport
Parameter: A Javascript object representation of your test suite report. See the type definitions for available properties.
options
Parameter: Optional object configuring the output. Properties:
schema: 'default' | 'ant-junit'
Default: 'default'
The required format of the resulting XML string. By default, this is set to the format expected by GitLab CI/CD. Alternative options:
'ant-junit'
: The format used by Azure DevOps. Conforms to this schema: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
Returns
An XML string in JUnit test report format.
Changelog
See CHANGELOG.
License
MIT © Vincent Tunru