I am attempting to set up Laravel Dusk in a Laravel 5.4 application. Executing php artisan dusk
does not launch a browser window as shown in this guide and I am trying to figure out why. PHPStorm complains that the ExampleTest
class created during execution of the php artisan dusk:install
command must implement the createApplication()
method, but I cannot find any mention of this method in:
ExampleTest class is as follows:
class ExampleTest extends DuskTestCase
{
/**
* A basic browser test example.
*
* @return void
*/
public function testBasicExample()
{
$this->browse(function ($browser) {
$browser->visit('/')
->assertSee('Laravel');
});
}
}
Yes, this is required.
One method to solve this is to simply add the code contained in the trait (from a later version of Laravel) to your DuskTestCase
.
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
return $app;
}
Alternatively, you can create the CreatesApplication
trait, paste the above code within in, and use CreatesApplication
within your DuskTestCase
.