You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

mocha-junit-reporter

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocha-junit-reporter

A JUnit reporter for mocha.

2.2.1
latest
Source
npmnpm
Version published
Weekly downloads
1.6M
2.45%
Maintainers
2
Weekly downloads
 
Created

What is mocha-junit-reporter?

The mocha-junit-reporter npm package is designed to generate JUnit-style XML test results from Mocha tests, which is particularly useful for integrating Mocha tests with continuous integration systems like Jenkins, CircleCI, or GitLab CI that can consume JUnit XML reports. This reporter is highly configurable and can be used both in command line and programmatically in Node.js.

What are mocha-junit-reporter's main functionalities?

JUnit XML Report Generation

This feature allows the generation of JUnit XML reports from Mocha tests. The code sample demonstrates how to set up Mocha with the mocha-junit-reporter to output test results in JUnit XML format to a specified file.

const Mocha = require('mocha');
const mocha = new Mocha({
  reporter: 'mocha-junit-reporter',
  reporterOptions: {
    mochaFile: './test-results/results.xml'
  }
});
mocha.addFile('./test/some-test.js');
mocha.run();

Configuration via Environment Variables

This feature supports configuring the reporter through environment variables. The code sample shows how to configure the output file and additional properties using environment variables before running the tests.

process.env.MOCHA_FILE = './test-results/results.xml';
process.env.PROPERTIES = 'HOSTNAME=localhost';

const Mocha = require('mocha');
const mocha = new Mocha({
  reporter: 'mocha-junit-reporter'
});
mocha.addFile('./test/some-test.js');
mocha.run();

Other packages similar to mocha-junit-reporter

Keywords

mocha

FAQs

Package last updated on 12 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts