Skip to content

Commit

Permalink
Fix #1864: xunit missing output with --reporter-options output
Browse files Browse the repository at this point in the history
  • Loading branch information
danielstjules committed Sep 9, 2015
1 parent 75a7f71 commit e950ea6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/reporters/xunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ function XUnit(runner, options) {
});
}

/**
* Inherit from `Base.prototype`.
*/
inherits(XUnit, Base);

/**
* Override done to close the stream (if it's a file).
*
Expand All @@ -93,11 +98,6 @@ XUnit.prototype.done = function(failures, fn) {
}
};

/**
* Inherit from `Base.prototype`.
*/
inherits(XUnit, Base);

/**
* Write out the given line.
*
Expand Down
31 changes: 30 additions & 1 deletion test/integration/reporters.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
var assert = require('assert');
var os = require('os');
var fs = require('fs');
var crypto = require('crypto');
var path = require('path');
var run = require('./helpers').runMocha;

describe('reporters', function() {
this.timeout(1000);
this.timeout(3000);

describe('markdown', function() {
var res;
Expand All @@ -28,4 +32,29 @@ describe('reporters', function() {
assert(res.output.indexOf(src) !== -1, 'No assert found');
});
});

describe('xunit', function() {
it('prints test cases with --reporter-options output (issue: 1864)', function(done) {
var randomStr = crypto.randomBytes(8).toString('hex');
var tmpDir = os.tmpDir().replace(new RegExp(path.sep + '$'), '');
var tmpFile = tmpDir + path.sep + 'test-issue-1864-' + randomStr + '.xml';

var args = ['--reporter=xunit', '--reporter-options', 'output=' + tmpFile];
var expectedOutput = [
'<testcase classname="suite" name="test1" time="0"/>',
'<testcase classname="suite" name="test2" time="0"/>',
'</testsuite>'
].join('\n');

run('passing.js', args, function(err, result) {
if (err) return done(err);

var xml = fs.readFileSync(tmpFile, 'utf8');
fs.unlinkSync(tmpFile);

assert(xml.indexOf(expectedOutput) !== -1, 'Did not output all xml');
done(err);
});
});
});
});

0 comments on commit e950ea6

Please sign in to comment.