telescope: Call to undefined method Illuminate\Support\Testing\Fakes\EventFake::getListeners()
Hi
We’ve just updated to Laravel 5.8, and using the latest Telescope v2.0.0, and we get this error in some unit tests - seems to be because Telescope is trying to run getListeners() and it doesn’t exist.
│ Error: Call to undefined method Illuminate\Support\Testing\Fakes\EventFake::getListeners()
│
│ /var/www/vendor/laravel/telescope/src/Watchers/EventWatcher.php:82
│ /var/www/vendor/laravel/telescope/src/Watchers/EventWatcher.php:46
│ /var/www/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:344
│ /var/www/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:196
│ /var/www/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/EventFake.php:201
│ /var/www/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/EventFake.php:257
│ /var/www/vendor/owen-it/laravel-auditing/src/Auditor.php:99
│ /var/www/vendor/owen-it/laravel-auditing/src/Auditor.php:65
│ /var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
│ /var/www/vendor/owen-it/laravel-auditing/src/AuditableObserver.php:38
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (8 by maintainers)
@themsaid I’m also getting this issue. I’ve tried to debug the code a bit and this is what happens for us when we have a test that fakes the event dispatcher:
I added a breakpoint at
EventFake:201
to see which events passed through this line and at first it was a bunch of eloquent events, which went fine, but as soon as an event from a library was passed to that line the exception occurs.Obviously Telescope ignores all the eloquent events, so this is the first event that occurs that Telescope tries to format the listeners for. Since faking events replaces the default event dispatcher with EventFake and EventFake doesn’t have a
getListeners()
method, Telescope’s event watcher can’t format the listeners for the given event.I hope this information helps a bit.
Thanks @jorenvh. That helped. I’ve sent in a fix for this here: https://github.com/laravel/telescope/pull/866
I just confirmed that Telescope is indeed not disabled by default during testing and nor should it. So we’ll investigate this issue.
@jorenvh Telescope should definitely be disabled when running your tests.