1
1
var fs = require ( 'fs' )
2
2
, filename = 'mocha.json' ;
3
3
4
+ var fE ;
4
5
5
- var bambooReporter = function ( baseReporterDecorator , config ) {
6
+ var bambooReporter = function ( baseReporterDecorator , config , formatError ) {
7
+ fE = formatError ;
6
8
baseReporterDecorator ( this ) ;
7
-
9
+
8
10
filename = config && config . filename || filename ;
9
-
11
+
10
12
var results = {
11
13
time : 0 , tests : [ ] , failures : [ ] , passes : [ ] , skips : [ ]
12
14
} ;
13
15
14
16
this . onRunStart = function ( ) {
15
17
this . _browsers = [ ] ;
16
18
if ( fs . existsSync ( filename ) ) {
17
- fs . unlinkSync ( filename ) ;
19
+ fs . unlinkSync ( filename ) ;
18
20
}
19
21
} ;
20
22
@@ -41,15 +43,27 @@ var bambooReporter = function (baseReporterDecorator, config) {
41
43
42
44
function clean ( test ) {
43
45
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
45
49
} ;
46
50
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
+ } ) ;
48
62
}
49
63
return o ;
50
64
}
51
65
52
- bambooReporter . $inject = [ 'baseReporterDecorator' , 'config.bambooReporter' ] ;
66
+ bambooReporter . $inject = [ 'baseReporterDecorator' , 'config.bambooReporter' , 'formatError' ] ;
53
67
54
68
// PUBLISH DI MODULE
55
69
module . exports = {
0 commit comments