Skip to content

*outdated* Single Page for multiple reports

Harry Hou edited this page Jan 15, 2022 · 1 revision

Notice this feature was not supported now.

Limitation

  • To access the page you must serve the page locally or have it hosted on a live server somewhere. LiveServer (an extension for Visual Studio Code was recommended for local server)
  • You need to clean the multiple report output folder manually every time before you run a series of tests.

Usage

Why need this?

It is a common use case in monorepos project, we will have multiple packages and each package have it owns tests, usually, we will run all test and would like to show those all test reports in a single HTML page.

...,
"reporters": [
  "default",
  ["jest-html-reporters", {
    "multipleReportsUnitePath": path.resolve(__dirname, "../../jest-report"), // set this configuration as a unite folder for each package.
    "pageTitle": 'UI Libs Report', // this will show as a tag name in result single Page
  }]
]

image

When all test was done, a single HTML report page named multiple-html-unite-report will be created in the specified folder. Each package's test result will have a tag at the top of the page, you can click it to switch the content.

How it works?


In fact, we can't do this. Jest do not provide a way to run multiple packages test, and in the reporter, we can not make any connection between the different test results. what we did just create a JSON file in the unified result folder, every time we finish a package's test, we append the data to the JSON file and display that data in the result page. Also, this is the reason for the two limitations.