Skip to content

Commit

Permalink
make sure the xunit output dir exists before trying to write to it
Browse files Browse the repository at this point in the history
Fixes #1994
  • Loading branch information
ianwremmel committed Dec 7, 2015
1 parent 1192914 commit 1cc21a9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/reporters/xunit.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var utils = require('../utils');
var inherits = utils.inherits;
var fs = require('fs');
var escape = utils.escape;
var mkdirp = require('mkdirp');

/**
* Save timer references to avoid Sinon interfering (see GH-237).
Expand Down Expand Up @@ -40,10 +41,11 @@ function XUnit(runner, options) {
var self = this;

if (options.reporterOptions && options.reporterOptions.output) {
if (!fs.createWriteStream) {
throw new Error('file output not supported in browser');
}
self.fileStream = fs.createWriteStream(options.reporterOptions.output);
if (! fs.createWriteStream) {
throw new Error('file output not supported in browser');
}
mkdirp.sync(path.dirname(options.reporterOptions.output));
self.fileStream = fs.createWriteStream(options.reporterOptions.output);
}

runner.on('pending', function(test) {
Expand Down

0 comments on commit 1cc21a9

Please sign in to comment.