How can I test event listeners? If I have a component that specifies some event listeners via the $listeners
property how can I test it reacts correctly to the event? Is there a way to mock the events or should I just test by calling the listener method?
Testing event listeners
I believe you can use Livewire::emit('eventName');
or Livewire::fireEvent('eventName');
They do the same thing, so your preference on how the code reads. I haven’t tried myself, but they are located in /Testing/Concerns/MakesCallsToComponent.php, and I haven’t seen any issues for it on github, so I assume they will work.
Yes, they seem to work fine. Thanks!