@@ -15,20 +15,27 @@ const defaults = {
1515 verbose : true
1616}
1717
18+ class TableWithoutColor extends Table {
19+ constructor ( opts = { } ) {
20+ super ( { ...opts , style : { head : [ ] , border : [ ] } } )
21+ }
22+ }
23+
1824const printResult = ( result , opts ) => {
1925 opts = Object . assign ( { } , defaults , opts )
2026 let strResult = ''
2127
2228 if ( opts . verbose ) {
2329 const chalk = new Chalk . Instance ( testColorSupport ( { stream : opts . outputStream , alwaysReturn : true } ) )
30+ const ColorSafeTable = chalk . level === 0 ? TableWithoutColor : Table
2431
25- const shortLatency = new Table ( {
32+ const shortLatency = new ColorSafeTable ( {
2633 head : asColor ( chalk . cyan , [ 'Stat' , '2.5%' , '50%' , '97.5%' , '99%' , 'Avg' , 'Stdev' , 'Max' ] )
2734 } )
2835 shortLatency . push ( asLowRow ( chalk . bold ( 'Latency' ) , asMs ( result . latency ) ) )
2936 logToLocalStr ( '\n' + shortLatency . toString ( ) )
3037
31- const requests = new Table ( {
38+ const requests = new ColorSafeTable ( {
3239 head : asColor ( chalk . cyan , [ 'Stat' , '1%' , '2.5%' , '50%' , '97.5%' , 'Avg' , 'Stdev' , 'Min' ] )
3340 } )
3441
@@ -37,7 +44,7 @@ const printResult = (result, opts) => {
3744 logToLocalStr ( requests . toString ( ) )
3845
3946 if ( opts . renderStatusCodes === true ) {
40- const statusCodeStats = new Table ( {
47+ const statusCodeStats = new ColorSafeTable ( {
4148 head : asColor ( chalk . cyan , [ 'Code' , 'Count' ] )
4249 } )
4350 Object . keys ( result . statusCodeStats ) . forEach ( statusCode => {
@@ -57,7 +64,7 @@ const printResult = (result, opts) => {
5764 logToLocalStr ( '' )
5865
5966 if ( opts . renderLatencyTable ) {
60- const latencies = new Table ( {
67+ const latencies = new ColorSafeTable ( {
6168 head : asColor ( chalk . cyan , [ 'Percentile' , 'Latency (ms)' ] )
6269 } )
6370 percentiles . map ( ( perc ) => {
@@ -85,7 +92,7 @@ const printResult = (result, opts) => {
8592 logToLocalStr ( `${ format ( result . mismatches ) } requests with mismatched body` )
8693 }
8794 if ( result . resets ) {
88- logToLocalStr ( `request pipeline was resetted ${ format ( result . resets ) } ${ result . resets === 1 ? 'time' : 'times' } ` )
95+ logToLocalStr ( `request pipeline was reset ${ format ( result . resets ) } ${ result . resets === 1 ? 'time' : 'times' } ` )
8996 }
9097
9198 function logToLocalStr ( msg ) {
0 commit comments