Takes your XMl xunit results and then turns it into a nice single HTML file
Have a look at the demo
Have a look at the v6 demo It isn't complete but if you are interested in an early look at what new features might be available and the new layout/styles please feel free
You can use xunit-viewer from the command line
First install it
npm i -g xunit-viewer
Then run it
xunit-viewer
you can also run it with these optional params, see the next section for what they default to
--results=file_or_folder
--ignore=pattern_a,pattern_b,pattern_c
--output=file_or_folder_or_console
--title="The title"
--port=8080
--watch
--color=false
--filter.suites.value="Suite names matching this value"
--filter.suites.types=all,pass,fail,skip,error,unknown
--filter.tests.value="Test names matching this value"
--filter.tests.types=all,pass,fail,skip,error,unknown
--filter.properties.value="Properties matching with key or value matching this value"
--filter.properties.types=all
If you want to run this from a node script instead of command line first install it
npm i -D xunit-viewer
Then from your scripts do the following
const XunitViewer = require('xunit-viewer/cli')
const result = XunitViewer({
results: '',
suites: [],
xml: '',
ignore: [],
output: false,
title: 'Xunit Viewer',
port: false,
watch: false,
color: true,
filter: {},
format: 'html'
})
all are optional, those are default values
results
the file or folder where the results are, defaults to where the cli is running from i.e.process.cwd()
suites
you can pass the JSON format in after using the parserxml
you can pass the xml string inignore
an array of patterns to ignore or a single string with a pattern to ignoreoutput
if folder will save a filexunit-viewer.html
to that folder, if a file will save to that file if'console'
then it will spit out the results to the consoletitle
title for the HTMLport
iffalse
it will not start a server, otherwise it will start serving the output and not save not save a file unless you also provideoutput
watch
will re run the cli when anything inresults
changes, if you have a port it will also update that via websocketscolor
ifoutput === 'console'
then it will either be in color or notfilter
will filter outsuites
,tests
andproperties
from the console output example
{
"suites": {
value: "Suite names matching this value",
type: ["all", "pass", "fail", "skip", "error", "unknown"],
},
"tests": {
value: "Test names matching this value",
type: ["all", "pass", "fail", "skip", "error", "unknown"],
},
"properties": {
value: "Properties matching with key or value matching this value",
type: ["all"]
},
}
format
default tohtml
which is the full HTML file, but you can also choosejson
if you want to use that json for your own view
if any value is invalid it will try and use default
You will need to bring in React if you are using the component
It works best with webpack setup but you should be able to work it out if you need to
This is the view which you can reuse
import React from 'react'
import XunitViewer from 'xunit-viewer/component/xunit-viewer'
import 'xunit-viewer/component/index.css'
let MyWrapper = () => {
return <XunitViewer xml='' suites={[]} title='' />
}
This has replaced Junit Viewer which is now deprecated this.
Better API Better View Uses React Nested Suites Using sockets and lighter
- add a repl
- meta data for slack
- make better stub data
- better error handling
- set up something which will parse in browser
- clean everything and write some more tests