@@ -4,6 +4,7 @@ const Config = require("./config"),
4
4
Constants = require ( "./constants" ) ,
5
5
utils = require ( "./utils" ) ,
6
6
request = require ( 'request' ) ,
7
+ specDetails = require ( './sync/failedSpecsDetails' ) ,
7
8
{ table, getBorderCharacters } = require ( 'table' ) ,
8
9
chalk = require ( 'chalk' ) ;
9
10
@@ -13,7 +14,7 @@ exports.pollBuildStatus = (bsConfig, buildId) => {
13
14
} ) . then ( ( data ) => {
14
15
printSpecsRunSummary ( ) ;
15
16
} ) . then ( ( data ) => {
16
- printFailedSpecsDetails ( data ) ;
17
+ return specDetails . failedSpecsDetails ( data ) ;
17
18
} ) . then ( ( successExitCode ) => {
18
19
return resolveExitCode ( successExitCode ) ; // exit code 0
19
20
} ) . catch ( ( nonZeroExitCode ) => {
@@ -36,68 +37,6 @@ let printSpecsRunSummary = () => {
36
37
37
38
} ;
38
39
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
-
101
40
let resolveExitCode = ( exitCode ) => {
102
41
return new Promise ( ( resolve , _reject ) => { resolve ( exitCode ) } ) ;
103
42
} ;
0 commit comments