@@ -4,6 +4,7 @@ const Config = require("./config"),
44 Constants = require ( "./constants" ) ,
55 utils = require ( "./utils" ) ,
66 request = require ( 'request' ) ,
7+ specDetails = require ( './sync/failedSpecsDetails' ) ,
78 { table, getBorderCharacters } = require ( 'table' ) ,
89 chalk = require ( 'chalk' ) ;
910
@@ -13,7 +14,7 @@ exports.pollBuildStatus = (bsConfig, buildId) => {
1314 } ) . then ( ( data ) => {
1415 printSpecsRunSummary ( ) ;
1516 } ) . then ( ( data ) => {
16- printFailedSpecsDetails ( data ) ;
17+ return specDetails . failedSpecsDetails ( data ) ;
1718 } ) . then ( ( successExitCode ) => {
1819 return resolveExitCode ( successExitCode ) ; // exit code 0
1920 } ) . catch ( ( nonZeroExitCode ) => {
@@ -36,68 +37,6 @@ let printSpecsRunSummary = () => {
3637
3738} ;
3839
39- /**
40- *
41- * @param {Array.<{specName: string, status: string, combination: string, sessionId: string}> } data
42- * @returns {Promise.resolve || Promise.reject }
43- */
44- // Example:
45- // [
46- // {specName: 'spec1.failed.js', status: 'Failed', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'},
47- // {specName: 'spec2.name.js', status: 'Skipped', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'},
48- // {specName: 'spec3.network.js', status: 'Failed', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'},
49- // {specName: 'spec6.utils.js', status: 'Failed', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'},
50- // {specName: 'spec8.alias.js', status: 'Skipped', combination: 'Win 10 / Chrome 78', sessionId: '3d3rdf3r...'}
51- // ]
52- let printFailedSpecsDetails = ( data ) => {
53- return new Promise ( ( resolve , reject ) => {
54- if ( data . length === 0 ) resolve ( 0 ) ; // return if no failed/skipped tests.
55-
56- let failedSpecs = false ;
57- let specResultHeader = Constants . syncCLI . FAILED_SPEC_DETAILS_COL_HEADER . map ( ( col ) => {
58- return chalk . blueBright ( col ) ;
59- } ) ;
60-
61- let specData = [ specResultHeader ] ; // 2-D array
62-
63- data . forEach ( ( spec ) => {
64- if ( spec . status && spec . status . toLowerCase ( ) === 'failed' && ! failedSpecs )
65- failedSpecs = true ;
66-
67- let specStatus = ( spec . status && spec . status . toLowerCase ( ) === 'failed' ) ?
68- chalk . red ( spec . status ) : chalk . yellow ( spec . status ) ;
69- specData . push ( [ spec . specName , specStatus , spec . combination , spec . sessionId ] ) ;
70- } ) ;
71-
72- let config = {
73- border : getBorderCharacters ( 'ramac' ) ,
74- columns : {
75- 0 : { alignment : 'left' } ,
76- 1 : { alignment : 'left' } ,
77- 2 : { alignment : 'left' } ,
78- 3 : { alignment : 'left' } ,
79- } ,
80- /**
81- * @typedef {function } drawHorizontalLine
82- * @param {number } index
83- * @param {number } size
84- * @return {boolean }
85- */
86- drawHorizontalLine : ( index , size ) => {
87- return ( index === 0 || index === 1 || index === size ) ;
88- }
89- }
90-
91- let result = table ( specData , config ) ;
92-
93- logger . info ( 'Failed / skipped test report' ) ;
94- logger . info ( result ) ;
95-
96- if ( failedSpecs ) reject ( 1 ) ; // specs failed, send exitCode as 1
97- resolve ( 0 ) ; // No Specs failed, maybe skipped, but not failed, send exitCode as 0
98- } ) ;
99- } ;
100-
10140let resolveExitCode = ( exitCode ) => {
10241 return new Promise ( ( resolve , _reject ) => { resolve ( exitCode ) } ) ;
10342} ;
0 commit comments