JavaScript / TypeScript
Test Suite Monitoring for Mocha
Monitor your Mocha test suite health with TestGlance
Get Started in 3 Steps
- 1Install the mocha-junit-reporter: `npm install --save-dev mocha-junit-reporter`
- 2Run Mocha with JUnit output: `mocha --reporter mocha-junit-reporter --reporter-options mochaFile=test-results/mocha.xml`
- 3Add the TestGlance GitHub Action to your CI workflow
GitHub Actions Workflow
# .github/workflows/test.yml
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- name: Run tests
run: npx mocha --reporter mocha-junit-reporter --reporter-options mochaFile=test-results/mocha.xml
- name: Report to TestGlance
if: always()
uses: testglance/action@v1
with:
api-key: ${{ secrets.TESTGLANCE_API_KEY }}
report-path: test-results/mocha.xmlWhat You Get
- ✓Flaky test detection — automatically identify tests that pass and fail intermittently
- ✓Duration trends — track which tests are getting slower over time
- ✓Health score — a single metric summarizing your test suite reliability
- ✓CI summary — rich test result summaries directly in your GitHub Actions runs
FAQ
How do I generate JUnit XML from Mocha?
Install mocha-junit-reporter and pass it as the reporter: `mocha --reporter mocha-junit-reporter --reporter-options mochaFile=test-results/mocha.xml`.
Can I use multiple Mocha reporters simultaneously?
Yes. Use the mocha-multi-reporters package to combine the default spec reporter with mocha-junit-reporter, so you get console output and XML at the same time.
Does TestGlance support Mocha nested describes?
Yes. Nested describe blocks appear as test suites in the JUnit XML output. TestGlance preserves the hierarchy when displaying results.
Start Monitoring Your Mocha Tests
Free to get started. Set up in under 5 minutes.
Get Started