question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optionally print response body/text on failure

See original GitHub issue

If 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:closed
  • Created 11 years ago
  • Reactions:3
  • Comments:22 (1 by maintainers)

github_iconTop GitHub Comments

17reactions
anoffcommented, Mar 22, 2016

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.

        .end((err, res) => {
          if (err) {
            console.error(res.error);
          }
          done(err);
        });
16reactions
timoxleycommented, Apr 16, 2013

meh. just console.log.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found