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.

Better error reporting

See original GitHub issue

Two things, really.

One: assertions are not thrown first-come first-served. If I have:

return request(app)
    .post('/api/sites')
    .send(site)
    .expect(201)
    .expect('Location', new RegExp('/api/site/\\d+'))
    .end()

And my app returns a 400 error, it fails on the ‘Location’ header, even though the .expect(201) method is called first. If I remove the .expect('Location', ...) method call, it does fail on 201 !== 400.

Truth be told, I’d rather have the HTTP status code checked before any headers, since it’s a “higher level”, but manual ordering in the source gives more control.

Secondly, if a body is available, it would be nice to report the body contents, at least optionally or on error conditions, since that can provide details as to why the request failed.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
kjarmickicommented, Jul 10, 2018

I was having the same issue with insufficient debugging information on failing status assertions, so I made a minimal plugin to capture and enhance errors: https://github.com/kjarmicki/supertest-capture-error It should give you enough flexibility to decorate assertion errors with valuable info.

0reactions
maldimirovcommented, Jun 8, 2018

+1 for printing the body on status code expectation fail. Right now I use supertest only for status and header assertions and Jest for body checking. The only way to check why a request has failed is to try/catch/log the script being tested.

Read more comments on GitHub >

github_iconTop Results From Across the Web

10 best error monitoring tools to use in 2022 - Raygun
Raygun Error Monitoring is a powerful, user-centric tool that gives you actionable insights into errors and crashes impacting your users. Raygun ...
Read more >
Designing Better Error Messages UX - Smashing Magazine
One simple way of doing so is to improve the discovery errors, by never relying on the color of error messages alone.
Read more >
Error Messages: Examples, Best Practices & Common Mistakes
How to write good error messages: The 4 H's · 1. Write for humans (be understandable) · 2. Make sure the message is...
Read more >
Best 10 Examples And Guidelines For Error Messages
Best 10 Examples And Guidelines For Error Messages · 1. Keep language clear and concise · 2. Keep user actions specific and logical...
Read more >
Error Reporting | Google Cloud
Real-time exception monitoring and alerting ... Error Reporting counts, analyzes, and aggregates the crashes in your running cloud services. A centralized error ...
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