Skip to content

Commit 980c5c9

Browse files
mattfyshTheSharpieOne
authored andcommitted
Improve Output
1 parent 9cb5ecf commit 980c5c9

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

index.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
var fs = require('fs')
22
, filename = 'mocha.json';
33

4+
var fE;
45

5-
var bambooReporter = function (baseReporterDecorator, config) {
6+
var bambooReporter = function (baseReporterDecorator, config, formatError) {
7+
fE = formatError;
68
baseReporterDecorator(this);
7-
9+
810
filename = config && config.filename || filename;
9-
11+
1012
var results = {
1113
time: 0, tests: [], failures: [], passes: [], skips: []
1214
};
1315

1416
this.onRunStart = function () {
1517
this._browsers = [];
1618
if (fs.existsSync(filename)) {
17-
fs.unlinkSync(filename);
19+
fs.unlinkSync(filename);
1820
}
1921
};
2022

@@ -41,15 +43,27 @@ var bambooReporter = function (baseReporterDecorator, config) {
4143

4244
function clean(test) {
4345
var o = {
44-
title: test.suite.join(' ') + ' on ' + test.browser, fullTitle: test.suite.join(' ') + ' ' + test.description + ' on ' + test.browser, duration: test.time
46+
title : test.suite.concat(test.description).join(' '),
47+
fullTitle : test.suite[0],
48+
duration : test.time
4549
};
4650
if (!test.success) {
47-
o.error = test.log.join('\n');
51+
o.error = '';
52+
test.log.forEach(function(log) {
53+
// translate sourcemap
54+
log = fE(log);
55+
o.error += log.split('\n').reduce(function(memo, line, i) {
56+
// keep first line
57+
line = line.split('<-');
58+
if (line[1]) memo += '\n\tat' + line[1];
59+
return memo;
60+
})
61+
});
4862
}
4963
return o;
5064
}
5165

52-
bambooReporter.$inject = ['baseReporterDecorator', 'config.bambooReporter'];
66+
bambooReporter.$inject = ['baseReporterDecorator', 'config.bambooReporter', 'formatError'];
5367

5468
// PUBLISH DI MODULE
5569
module.exports = {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "karma-bamboo-reporter",
3-
"version": "0.0.2",
3+
"version": "0.1.0",
44
"author": "TheSharpieOne",
55
"license": "MIT",
66
"homepage": "https://github.com/TheSharpieOne/karma-bamboo-reporter",

0 commit comments

Comments
 (0)