spatie / laravel-blade-comments

Add debug comments to your rendered output
https://freek.dev/2500-a-laravel-package-to-quickly-see-which-html-is-rendered-by-which-blade-view
MIT License
162 stars 9 forks source link

[Bug]: Incompatible with TestResponse view assertions #29

Open mortenscheel opened 2 months ago

mortenscheel commented 2 months ago

What happened?

If this package is active during features tests, the test will fail if any of these methods are called on TestResponse:

These methods all expect the response's $original attribute to contain a View instance, which it doesn't after the AddRequestComments middleware has called $response->setContent().

How to reproduce the bug

  1. Enable the package during feature tests.
  2. Call a route that returns a View and call one of the mentioned assertions on the response.

Package Version

1.3.0

PHP Version

8.3.11

Laravel Version

11.22.0

Which operating systems does with happen with?

No response

Notes

I realize that by default this package is enabled via APP_DEBUG which usually won't be true during testing. But since it's configurable, you can't assume that it will always be disabled during unit tests.

If it's not possible for AddRequestComments to prevent replacing the $original attribute, it's probably best to disable the middleware entirely during tests (maybe controlled by a separate config option).