Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to inherit from spec instead of base reporter #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

var xml = require('xml');
var Base = require('mocha').reporters.Base;
var Spec = require('mocha').reporters.Spec;
var fs = require('fs');
var path = require('path');
var inherits = require('util').inherits;
var debug = require('debug')('mocha-junit-reporter');
var mkdirp = require('mkdirp');
var md5 = require('md5');
Expand Down Expand Up @@ -217,8 +219,13 @@ function MochaJUnitReporter(runner, options) {
return testsuites[testsuites.length - 1].testsuite;
}

// get functionality from the Base reporter
Base.call(this, runner);
if (this._options.spec) {
// get functionality from the Spec reporter
Spec.call(this, runner);
} else {
// get functionality from the Base reporter
Base.call(this, runner);
}

// remove old results
this._runner.on('start', function() {
Expand Down Expand Up @@ -276,6 +283,8 @@ function MochaJUnitReporter(runner, options) {
}.bind(this));
}

inherits(MochaJUnitReporter, Base);

/**
* Produces an xml node for a test suite
* @param {Object} suite - a test suite
Expand Down