Skip to content

Commit

Permalink
fix junit reporter write file
Browse files Browse the repository at this point in the history
  • Loading branch information
uxter committed Jun 19, 2017
1 parent 21a4508 commit f40ecbd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"gui"
],
"main": "lib/guit.js",
"version": "1.4.10",
"version": "1.4.11",
"license": "ISC",
"repository": {
"type": "git",
Expand All @@ -28,6 +28,7 @@
"expect": "^1.20.2",
"express": "^4.14.1",
"image-diff": "^1.6.3",
"mkdirp": "^0.5.1",
"phantom": "^4.0.0",
"recursive-readdir-sync": "^1.0.6",
"socket.io": "^1.7.3",
Expand Down
10 changes: 9 additions & 1 deletion src/reporter/junit-reporter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs';
import path from 'path';
import mkdirp from 'mkdirp';
import builder from 'xmlbuilder';

export default class JunitReporter {
Expand Down Expand Up @@ -90,7 +91,14 @@ export default class JunitReporter {
this.testSuites['@time'] = (Date.now() - this.startTime) / 1000;
let xml = builder.create('testsuites', { version: '1.0', encoding: 'UTF-8' })
.ele(this.testSuites).end({ pretty: true});
fs.writeFileSync(path.join(process.cwd(), this.filename), xml);
let fileName = path.join(process.cwd(), this.filename);
mkdirp(path.dirname(fileName), err => {
if (err) {
console.error(err);
} else {
fs.writeFileSync(fileName, xml);
}
});
}

}

0 comments on commit f40ecbd

Please sign in to comment.