-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[8.x] Track exceptions and display them on failed status checks for dx #38025
Conversation
src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Dries Vints <[email protected]>
It's uncountable how many times I've wanted this. |
👌 |
To all those |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a brilliant DX improvement and will save a lot of time and frustration! Thank you 😁
In the spirit of removing the need to add temporary debugging code, I wonder whether there is also an opportunity to improve the output on an unexpected validation exception. Currently I get this a fair bit: Even without exception handling (which this PR removes the need for 😁), the output is no more helpful: So I end up needing to add a temporary If this sounds useful, I'm happy to have a go once this PR is merged. I'm thinking if it's a JSON request then it should show the errors as JSON, otherwise perhaps just a |
@jessarcher sounds like a good idea |
This feature is inspired by feedback from @jessarcher and my own poor experience with testing endpoints that throw unexpected exceptions.
This problem typically arises when asserting against the status of a test response and receiving a failed assertions indicating the expected status code did not match the actual status code of
500
. You must then examine your logs to hopefully determine what the exception message was. Or, you can call$this->withoutExceptionHandling()->get(...)
to disable exception handling for the test.Ideally, Laravel would just show you the exception. This PR takes care of that by tracking exceptions while running unit tests and then displaying the exception failed status checks where the actual status code is
500
.