title: How to resolve 'The expected [App\Events\UserRegistered] event was not dispatched.' error?
body: <p>I have created a feature called <code>test</code> to test the admin registration. When i run the testcases it gives me this error</p>
  
  <pre><code> 1) Tests\Feature\Admin\RegisterTest::testValidRegistration
    The expected [App\Events\UserRegistered] event was not dispatched. 
   Failed asserting that false is true.
  
   /var/www/html/gas-backend/tests/Feature/Admin/RegisterTest.php:85
  </code></pre>
  
  <p>Below i have stated the admin registration test file and user registered event file</p>
  
  <p><strong>Admin/RegisterTest.php</strong></p>
  
  <pre><code>$response-&gt;assertStatus(201);
          $response-&gt;assertJson($expectedResponse);
          $this-&gt;assertDatabaseHas('users', $expectedDatabaseRecord);
          Event::assertDispatched(UserRegistered::class);
          Notification::assertNotSentTo($user, RegistrationComplete::class);
  </code></pre>
  
  <p><strong>UserRegistered.php</strong></p>
  
  <pre><code>&lt;?php
  
  namespace App\Events;
  
  use Illuminate\Broadcasting\Channel;
  use Illuminate\Broadcasting\InteractsWithSockets;
  use Illuminate\Broadcasting\PresenceChannel;
  use Illuminate\Broadcasting\PrivateChannel;
  use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
  use Illuminate\Foundation\Events\Dispatchable;
  use Illuminate\Queue\SerializesModels;
  use App\Models\User;
  
  class UserRegistered
  {
      use Dispatchable, InteractsWithSockets, SerializesModels;
  
      public $user;
  
      /**
       * Create a new event instance.
       *
       * @return void
       */
      public function __construct(User $user)
      {
          $this-&gt;user = $user;
      }
  
      /**
       * Get the channels the event should broadcast on.
       *
       * @return \Illuminate\Broadcasting\Channel|array
       */
      public function broadcastOn()
      {
          //return new PrivateChannel('channel-name');
      }
  }
  
  </code></pre>
  
  <p>How should i resolve this error ?</p>