Skip to main content
In this lesson, we’ll archive JUnit-format Mocha test reports in GitHub Actions using actions/upload-artifact. Previously, our workflow ran unit tests successfully but didn’t persist the generated XML report:
Locally, the mocha-junit-reporter creates a test-results.xml file in your project root. For example:
To archive this file in CI, add a step that uses actions/upload-artifact@v3:
The path field accepts glob patterns. To archive multiple XML reports, use something like path: reports/**/*.xml.
After the workflow runs, open the Actions tab to confirm the artifact upload. You’ll see a log entry showing the artifact size and success:
The image shows a GitHub Actions interface with a successful unit testing job. It includes details about the steps involved, such as checking out the repository, setting up NodeJS, installing dependencies, and archiving test results.
In the workflow summary, the uploaded artifact is listed under the Unit Testing job:
The image shows a GitHub Actions interface with a successful unit testing job, including details about the "Mocha-Test-Result" artifact being uploaded.
By default, artifacts are retained for 90 days. You can configure retention or delete them when they’re no longer needed.
Archiving your test reports guarantees that JUnit XML outputs are always available for debugging, reporting, or integration with CI dashboards once your workflow completes.

Watch Video