Is there a way to control the printer to print the Request Body and Response Body only on failure? #138
-
Is there a way to control the printer to print the Request Body and Response Body only on failure? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi. Unfortunately, there is no way to do it. I guess it would not be easy to implement it, since currently we're printing request and response before constructing Response objects, on which the user performs assertions. To achieve the behavior you need, we should maintain some context with both request and response and pass it to every object that may perform assertions (e.g. Value, Object, Array, etc.). More specifically, we should add it to Here is where request and response are printed currently: Lines 893 to 917 in 0387206 |
Beta Was this translation helpful? Give feedback.
Hi. Unfortunately, there is no way to do it.
I guess it would not be easy to implement it, since currently we're printing request and response before constructing Response objects, on which the user performs assertions.
To achieve the behavior you need, we should maintain some context with both request and response and pass it to every object that may perform assertions (e.g. Value, Object, Array, etc.). More specifically, we should add it to
chain
object and forward to child chains. Thenchain
can use this context to print desired info on failure.Here is where request and response are printed currently:
httpexpect/request.go
Lines 893 to 917 in 0387206