Optionally print response body/text on failure
See original GitHub issueIf I get a wrong status code back from a controller, it’d be nice if supertest had an optional ‘print response body on failure’ mode so I can see the content of the message associated with that wrong status code. Currently you have to go in and manually add additional debugging into like: .expect(200, function() { console.log(arguments); done(); })
every time a test starts failing.
Another option might be to be smarter about generating the Error response in supertest, e.g. parsing the res.body and (optionally) jamming that into the error message. It could even somehow do some specialcase handling of the default connect error handler to populate the stack trace (if that’s even possible).
Issue Analytics
- State:
- Created 11 years ago
- Reactions:3
- Comments:22 (1 by maintainers)
Top Results From Across the Web
Optionally print response body/text on failure #12 - GitHub
This results in error messages such as the following, which is output from a test that failed a response body checker. Error: expect(received)....
Read more >Retrofit 2.0 how to get deserialised error response.body
There is a way to get the error body string from the response without making it empty on the next call, by rolling...
Read more >Response - Web APIs - MDN Web Docs - Mozilla
Returns a promise that resolves with a text representation of the response body.
Read more >HttpResponse.BodyHandlers (Java SE 12 & JDK 12 )
Receives the response body as a String HttpResponse<String> response = client ... Subscriber<String> // and print lines received by onNext() on System.out ...
Read more >Response in reqwest - Rust - Docs.rs
Get the full response text. This method decodes the response body with BOM sniffing and with malformed sequences replaced with the REPLACEMENT CHARACTER....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If anyone stumbles upon this and wonders how to log at all. Appending this to your test case logs if an error occurs and rethrows the error via done.
meh. just console.log.