Question: I have a `WelcomeNotification` which implements `ShouldQueue`

```php
class WelcomeNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public function via($notifiable)
    {
        return ['mail'];
    }

    public function toMail($notifiable)
    {
        // send a welcome message to the user via mailtrap
    }

}

```

How can I test if this notification has been pushed to the queue?

I am trying to test it like this but I am getting 
`The expected [App\Notifications\WelcomeNotification] job was not pushed`

```php
    /** @test */
    public function welcome_notification_is_pushed_to_queue()
    {
        Queue::fake();

        $this->post(route('register'), [
            'name' => 'John Doe',
            'email' => 'john@test.com',
            'password' => 'passwordtest',
        ]);

        Queue::assertPushed(WelcomeNotification::class);
    }

```

Inside my registered function in `RegisterController`:

```php
    protected function registered(Request $request, $user)
    {
          $user->notify(new WelcomeNotification());
          // other code
    }

```

I have successfully asserted that `WelcomeNotification` is correctly being sent to the user when registering using `Notification::assertSentTo`. 

**My issue is how to test if `WelcomeNotification` was pushed to the queue or not?**

Answer: 
Use this instead of the loop:

```
results_df <- lapply(urls, function(u) {
  message(u)

  aktuellewohnung <- read_html(u)

  Baujahr <- aktuellewohnung %>%
    html_nodes("#is24-content > div.grid-item.padding-desk-right-xl.desk-two-thirds.lap-one-whole.desk-column-left.flex-item.palm--flex__order--1.lap--flex__order--1 > div.is24-ex-details.main-criteria-headline-size.two-column-layout > div.criteriagroup.flex.flex--wrap.criteria-group--spacing.padding-top-s > div.criteriagroup.criteria-group--border.criteria-group--two-columns.criteria-group--spacing > dl:nth-child(1) > dd") %>%
    html_text()
  Energie <- aktuellewohnung %>%
    html_nodes("#is24-content > div.grid-item.padding-desk-right-xl.desk-two-thirds.lap-one-whole.desk-column-left.flex-item.palm--flex__order--1.lap--flex__order--1 > div.is24-ex-details.main-criteria-headline-size.two-column-layout > div.criteriagroup.flex.flex--wrap.criteria-group--spacing.padding-top-s > div.criteriagroup.criteria-group--border.criteria-group--two-columns.criteria-group--spacing > dl:nth-child(7) > dd") %>%
    html_text() 
  tibble(
    Baujahr = ifelse(length(Baujahr) == 0, NA, Baujahr),
    Energie = ifelse(length(Energie) == 0, NA, Energie)
  )
}) %>% 
  bind_rows()

```

The `lapply` loop will return a list of `data.frames` which have `NA` if the field couldn't be found. `bind_rows()` transforms those into one `data.frame`.
Try using `trycatch` [function](https://www.rdocumentation.org/packages/R.oo/versions/1.2.7/topics/trycatch) when assigning the value:

```
Baujahr[i] <- tryCatch({aktuellewohnung %>%
    html_nodes("#is24-content > div.grid-item.padding-desk-right-xl.desk-two-thirds.lap-one-whole.desk-column-left.flex-item.palm--flex__order--1.lap--flex__order--1 > div.is24-ex-details.main-criteria-headline-size.two-column-layout > div.criteriagroup.flex.flex--wrap.criteria-group--spacing.padding-top-s > div.criteriagroup.criteria-group--border.criteria-group--two-columns.criteria-group--spacing > dl:nth-child(1) > dd") %>%
    html_text()},error = function(cond){NA})

```