Skip to content
Advertisement

Freshly generated DuskTestCase.php throws “Undefined type ‘TestsCreatesApplication'”

I’m trying to set up Laravel Dusk to test my Laravel site as part of a larger Github Action CI/CD workflow.

Following the documentation, I ran:

JavaScript

The latter command created a tests/Browser directory and a tests/DuskTestCase.php file.

The problem is that when I open up DuskTestCase.php Intelephense immediately complains:

JavaScript

I also get a slightly different, but clearly related, error when running the GitHub Action:

JavaScript

I have the following in my composer.json:

JavaScript

…and have also run composer dump-autoload locally.

What’s going on here? Why does the example test file generated by Dusk seem to ship with an error and what can I do to fix it?

Advertisement

Answer

Have you deleted the CreatesApplication from your app? It comes out of the box with a fresh Laravel installation: https://github.com/laravel/laravel/blob/9.x/tests/CreatesApplication.php

Alternatively perhaps you upgraded from an earlier version of Laravel and missed the addition of this file.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement