I am following along this course testdrivenlaravel, and it mentions a way disable the Laravel's exception handling to prevent Laravel from handling exceptions that occur and instead throwing it, so we can get a more detailed error in our tests output.
So I added this method in my testcase class, and in the render method I am throwing the exception
protected function disableExceptionHandling() {
$this->app->instance(Handler::class, new class extends Handler {
public function __construct()
{
}
public function report(\Exception $e)
{
}
public function render($request, \Exception $e)
{
throw $e;
}
});
}
But whenever I call it in a test, to get more detailed error, I still get the same errors that Laravel Handler is rendering.
When I change the Handler
class directly like this:
public function render($request, Exception $exception)
{
throw $exception;
// return parent::render($request, $exception);
}
I get the detailed errors, but I need to get the disableExceptionHandling
helper work.