Jest
Jest is a testing framework for Javascript and Typescript.
Enabling XML Output
Configure Jest to produce JUnit XML output.
Install the jest-junit.
Update your Jest config (jest.config.json
or similar file) to add jest-junit
as a reporter.
jest.config.json
With this configuration, Jest runs with by default output a junit.xml
file in the working directory. To further configure the reporter, consult the detailed documentation on GitHub.
Test Suite Naming
The jest-junit
reporter will automatically fill in values for the and name
and class
attributes using the description parameters to the tests. The testsuites.name
is set to jest tests
by default.
To make it easier to debug, it is also useful to include the name of the file that the failing test is in. You can do this by adding this to the jest.config.json
file.
For example, this test:
would produce output that looks like this:
The default attributes can be changed using jest-junit
configuration settings.
Further Information
See an example of running Jest inside of a GitHub action here.
Jest is highly customizable. See more at the Jestjs.io homepage.
Last updated