A Karma plugin. Report results in junit xml format.
Last updated 3 years ago by h-ikeda .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install karma-surrogate-junit-reporter 
SYNC missed versions from official npm registry.

This is folked package of karma-junit-reporter. Same as #126 Added allowSurrogateChars option.


js-standard-style npm version npm downloads

Build Status Dependency Status devDependency Status

Reporter for the JUnit XML format.


The easiest way is to keep karma-surrogate-junit-reporter as a devDependency in your package.json. Just run

npm install karma-surrogate-junit-reporter --save-dev

to let npm automatically add it there.


// karma.conf.js
module.exports = function(config) {
    reporters: ['progress', 'junit'],

    // the default configuration
    junitReporter: {
      outputDir: '', // results will be saved as $outputDir/$browserName.xml
      outputFile: undefined, // if included, results will be saved as $outputDir/$browserName/$outputFile
      suite: '', // suite will become the package name attribute in xml testsuite element
      useBrowserName: true, // add browser name to report and classes names
      nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
      classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
      properties: {} // key value pair of properties to add to the <properties> section of the report

You can pass list of reporters as a CLI argument too:

karma start --reporters junit,dots

Produce test result with schema acceptable in sonar

To make this possible, it's required to make the classnames of each tests to match its file name.

For Example:

describe('analytics.AnalyticsModule_test', function(){

    var analytics;

should have a file name AnalyticsModule_test.js

This will produce test result with schema acceptable in sonar.

Grunt file reporters property example:

reporters: ['junit', 'coverage', 'progress'],
junitReporter: {
    outputDir: $junitResults,
    suite: 'models'
coverageReporter: {
    type: 'lcov',
    dir: $coverageOutputDir,
    subdir: '.'
preprocessors: {
    'src/main/webapp/public/js/ec3.3/**/*.js': 'coverage',
    'src/main/webapp/public/js/ec3/**/*.js': 'coverage'
plugins: [

Sonar property example:


Example junit xml report:

<?xml version="1.0"?>
<testsuite name="PhantomJS 1.9.8 (Linux)" package="models" timestamp="2015-03-10T13:59:23" id="0" hostname="admin" tests="629" errors="0" failures="0" time="11.452">
    <property name="browser.fullName" value="Mozilla/5.0 (Unknown; Linux x86_64) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.8 Safari/534.34"/>
 <testcase name="(C.2) Checks if an empty object is returned when error 404 is encountered" time="0.01" classname="PhantomJS_1_9_8_(Linux).models.AnalyticsModule_test"/>
 <testcase name="(C.3) Checks if an empty array is returned when error 405 is encountered" time="0.013" classname="PhantomJS_1_9_8_(Linux).models.AnalyticsModule_test"/>

For more information on Karma see the homepage.

Current Tags

  • 1.2.0                                ...           latest (3 years ago)

1 Versions

  • 1.2.0                                ...           3 years ago
Maintainers (1)
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (18)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |