@@ -15,20 +15,27 @@ const defaults = {
15
15
verbose : true
16
16
}
17
17
18
+ class TableWithoutColor extends Table {
19
+ constructor ( opts = { } ) {
20
+ super ( { ...opts , style : { head : [ ] , border : [ ] } } )
21
+ }
22
+ }
23
+
18
24
const printResult = ( result , opts ) => {
19
25
opts = Object . assign ( { } , defaults , opts )
20
26
let strResult = ''
21
27
22
28
if ( opts . verbose ) {
23
29
const chalk = new Chalk . Instance ( testColorSupport ( { stream : opts . outputStream , alwaysReturn : true } ) )
30
+ const ColorSafeTable = chalk . level === 0 ? TableWithoutColor : Table
24
31
25
- const shortLatency = new Table ( {
32
+ const shortLatency = new ColorSafeTable ( {
26
33
head : asColor ( chalk . cyan , [ 'Stat' , '2.5%' , '50%' , '97.5%' , '99%' , 'Avg' , 'Stdev' , 'Max' ] )
27
34
} )
28
35
shortLatency . push ( asLowRow ( chalk . bold ( 'Latency' ) , asMs ( result . latency ) ) )
29
36
logToLocalStr ( '\n' + shortLatency . toString ( ) )
30
37
31
- const requests = new Table ( {
38
+ const requests = new ColorSafeTable ( {
32
39
head : asColor ( chalk . cyan , [ 'Stat' , '1%' , '2.5%' , '50%' , '97.5%' , 'Avg' , 'Stdev' , 'Min' ] )
33
40
} )
34
41
@@ -37,7 +44,7 @@ const printResult = (result, opts) => {
37
44
logToLocalStr ( requests . toString ( ) )
38
45
39
46
if ( opts . renderStatusCodes === true ) {
40
- const statusCodeStats = new Table ( {
47
+ const statusCodeStats = new ColorSafeTable ( {
41
48
head : asColor ( chalk . cyan , [ 'Code' , 'Count' ] )
42
49
} )
43
50
Object . keys ( result . statusCodeStats ) . forEach ( statusCode => {
@@ -57,7 +64,7 @@ const printResult = (result, opts) => {
57
64
logToLocalStr ( '' )
58
65
59
66
if ( opts . renderLatencyTable ) {
60
- const latencies = new Table ( {
67
+ const latencies = new ColorSafeTable ( {
61
68
head : asColor ( chalk . cyan , [ 'Percentile' , 'Latency (ms)' ] )
62
69
} )
63
70
percentiles . map ( ( perc ) => {
@@ -85,7 +92,7 @@ const printResult = (result, opts) => {
85
92
logToLocalStr ( `${ format ( result . mismatches ) } requests with mismatched body` )
86
93
}
87
94
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' } ` )
89
96
}
90
97
91
98
function logToLocalStr ( msg ) {
0 commit comments