Better error reporting
See original GitHub issueTwo 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:
- Created 9 years ago
- Comments:5
Top 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 >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
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.
+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.