-
-
Notifications
You must be signed in to change notification settings - Fork 243
Closed
Labels
featureNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedContributions are welcomeContributions are welcome
Milestone
Description
Follow-up for #159
Currently defaultFailureTemplate
colorizes requests/responses as follows:
{{ .Request | indent | trim | color $.EnableColors "HiMagenta" }}
{{ .Response | indent | trim | color $.EnableColors "HiMagenta" }}
The following improvement is suggested:
- add new function "colorhttp" to defaultTemplateFuncs and use it for request and response
- if colors are disabled, the function will return original value
- the function will apply the following colorization:
- in lines like
GET /test HTTP/1.1
it will highlightGET
(method) andHTTP/1.1
(protocol) - in lines like
HTTP/1.1 200 OK 229.642µs
it will highlightHTTP/1.1
(protocol) and200 OK
(status code) - in lines like
Host: 127.0.0.1:38681
it will highlightHost:
(header field name)
- in lines like
- the suggested color for highlighting is HiMagenta (in line with Colorize json values #334)
Example for testing:
$ FORCE_COLOR=1 go test -v -run TestE2EReport_Names
=== RUN TestE2EReport_Names
e2e_report_test.go:52:
invalid "Content-Type" response header
mime: no media type
test name: TestExample
request name: RequestExample
request: GET /test HTTP/1.1
Host: 127.0.0.1:35779
response: HTTP/1.1 200 OK 246.75µs
Date: Wed, 22 Mar 2023 18:38:49 GMT
Content-Length: 0
assertion:
Request("GET").Expect().JSON()
actual value:
""
--- PASS: TestE2EReport_Names (0.00s)
PASS
ok github.com/gavv/httpexpect/v2 0.003s
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedContributions are welcomeContributions are welcome