I am trying to run Laravel Dusk tests, but when I run the test, a new Chrome tab pops up with this message.
Fatal error: Class 'Tests\DuskTestCase' not found in path-to-project\tests\Browser\ExampleTest.php on line 9
All I have done so far is run composer require --dev laravel/dusk:^1.0
and php artisan dusk:install
.
This is my ExampleTest.php (exactly how Laravel set it up)
<?php
namespace Tests\Browser;
use Laravel\Dusk\Chrome;
use Tests\DuskTestCase;
use Laravel\Dusk\DuskServiceProvider;
class ExampleTest extends DuskTestCase
{
/**
* A basic browser test example.
*
* @return void
*/
public function testBasicExample()
{
$this->browse(function ($browser) {
$browser->visit('/')
->assertSee('Laravel');
});
}
}
DuskTestCase.php is also just as Laravel set it up and has the namespace namespace Tests;
.
I am using Laravel 5.4 and Dusk 1.0. I am running the test through PhpStorm, using the work around described here.
Anyone know why DuskTestCase can't seem to be found, even though it appears to be set up correctly? Thanks in advance.
If
composer dump-autoload
does not solve problem, you can try these steps.php artisan serve
. If homepage is accessible in your browser now, then you can try dusk again. In that case, remember to update your .env file to match APP_URL=http://127.0.0.1:8000, and run php artisan dusk from another cli window, causephp artisan serve
needs to be running also.if you test using a phpstrom then u have set path of phpunit ...... in settings/languages & framework/php/test frameworks and use composer autoloader path and then select a path of your laravel dusk project with autoload.php file..... set file a vendor/autoload.php file in path to script...
In composer.json:
add
"Tests\\": "tests/"
inthen, run
composer dump-autoload
to reload your packages.