Skip to content

Is there a way to control the printer to print the Request Body and Response Body only on failure? #138

Answered by gavv
arvind-sys asked this question in Q&A
Discussion options

You must be logged in to vote

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. Then chain 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

for _, printer := range r

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by gavv
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #138 on November 12, 2022 20:33.