@@ -39,6 +39,104 @@ exports.Server = function Server(bsClient, workers, config, callback) {
3939 return browserReport ;
4040 }
4141
42+ function reformatJasmineReport ( browserReport ) {
43+ var results = browserReport . suites ;
44+ browserReport . tests = browserReport . tests || [ ] ;
45+ browserReport . suites = {
46+ fullName : [ ] ,
47+ childSuites : [ ] ,
48+ tests : [ ] ,
49+ status : ! results . failed ? 'passed' : 'failed' ,
50+ testCounts : {
51+ passed : results . passed ,
52+ failed : results . failed ,
53+ skipped : results . skipped ,
54+ total : results . total ,
55+ } ,
56+ runtime : results . runtime
57+ } ;
58+ function recurseThroughSuites ( jasmineSuite , par ) {
59+ if ( ! jasmineSuite ) {
60+ return ;
61+ }
62+ var suite = {
63+ name : jasmineSuite . description ,
64+ fullName : [ ] ,
65+ childSuites : [ ] ,
66+ tests : [ ] ,
67+ status : jasmineSuite . passed ? 'passed' : 'failed' ,
68+ testCounts : {
69+ passed : 0 ,
70+ failed : 0 ,
71+ skipped : 0 ,
72+ total : 0
73+ } ,
74+ runtime : 0
75+ } ;
76+ if ( par . name ) {
77+ suite . fullName . push ( par . name ) ;
78+ }
79+ suite . fullName . push ( jasmineSuite . description ) ;
80+ jasmineSuite . specs . forEach ( function ( spec ) {
81+ var test = {
82+ name : spec . description ,
83+ suiteName : suite . decription ,
84+ fullName : [
85+ ] ,
86+ status : spec . passed ? 'passed' : ( spec . results . skipped ? 'skipped' : 'failed' ) ,
87+ runtime : spec . durationSec ,
88+ errors : [ ] ,
89+ assertions : [ ]
90+ } ;
91+ Array . prototype . push . apply ( test . fullName , suite . fullName ) ;
92+ test . fullName . push ( spec . description ) ;
93+ if ( ! spec . passed ) {
94+ spec . results . items_ . forEach ( function ( jasmineItem ) {
95+ if ( ! jasmineItem . passed_ ) {
96+ var detail = {
97+ passed : false
98+ } ;
99+ if ( 'message' in jasmineItem ) {
100+ detail . message = jasmineItem . message ;
101+ }
102+ if ( 'actual' in jasmineItem ) {
103+ detail . actual = jasmineItem . actual ;
104+ }
105+ if ( 'expected' in jasmineItem ) {
106+ detail . expected = jasmineItem . expected ;
107+ }
108+ if ( 'trace' in jasmineItem ) {
109+ detail . stack = jasmineItem . trace . message || jasmineItem . trace . stack ;
110+ }
111+ test . errors . push ( detail ) ;
112+ test . assertions . push ( detail ) ;
113+ }
114+ } ) ;
115+ }
116+ suite . tests . push ( test ) ;
117+ browserReport . tests . push ( test ) ;
118+ if ( spec . passed ) {
119+ ++ suite . testCounts . passed ;
120+ }
121+ else if ( spec . skipped ) {
122+ ++ suite . testCounts . skipped ;
123+ }
124+ else {
125+ ++ suite . testCounts . failed ;
126+ }
127+ ++ suite . testCounts . total ;
128+ suite . runtime += spec . durationSec ;
129+ } ) ;
130+ jasmineSuite . suites . forEach ( function ( childSuite ) {
131+ recurseThroughSuites ( childSuite , suite ) ;
132+ } ) ;
133+ par . childSuites . push ( suite ) ;
134+ }
135+ results . report . suites . forEach ( function ( jasmineSuite ) {
136+ recurseThroughSuites ( jasmineSuite , browserReport . suites ) ;
137+ } ) ;
138+ }
139+
42140 function handleFile ( filename , request , response , doNotUseProxy ) {
43141 var url_parts = url . parse ( request . url , true ) ;
44142 var query = url_parts . query ;
@@ -293,6 +391,7 @@ exports.Server = function Server(bsClient, workers, config, callback) {
293391 color = ( query . total !== query . passed ) ? 'red' : 'green' ;
294392 logger . info ( '[%s] ' + chalk [ color ] ( ( query . total !== query . passed ) ? 'Failed:' : 'Passed:' ) + ' %d tests, %d passed, %d failed; ran for %dms' , browserInfo , query . total , query . passed , query . failed , query . runtime ) ;
295393 config . status += query . failed ;
394+ reformatJasmineReport ( browserReport ) ;
296395 } else if ( query . testCounts ) {
297396 color = query . status === 'failed' ? 'red' : 'green' ;
298397 logger . info ( '[%s] ' + chalk [ color ] ( query . status === 'failed' ? 'Failed:' : 'Passed:' ) + ' %d tests, %d passed, %d failed, %d skipped; ran for %dms' , browserInfo , query . testCounts . total , query . testCounts . passed , query . testCounts . failed , query . testCounts . skipped , query . runtime ) ;
0 commit comments