From 2d6c5d70d7302a45556e1bdf8a7a44c7391b8aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20St=C3=B8len?= Date: Wed, 26 Apr 2023 19:01:09 +0200 Subject: [PATCH] Prevent panic if flag.Parse hasn't been called (#411) --- formatter.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/formatter.go b/formatter.go index 9361a6dd6..f0f372966 100644 --- a/formatter.go +++ b/formatter.go @@ -3,6 +3,7 @@ package httpexpect import ( "bytes" "encoding/json" + "flag" "fmt" "math" "net/http/httputil" @@ -319,7 +320,7 @@ func (f *DefaultFormatter) fillGeneral( case colorsForced: data.EnableColors = true case colorsSupported: - data.EnableColors = ctx.TestingTB && testing.Verbose() + data.EnableColors = ctx.TestingTB && flag.Parsed() && testing.Verbose() } case ColorModeAlways: data.EnableColors = true