itsjoshbruce's avatar

Laravel Dusk Test Cases in Different Sub-Dir than Browser

Does this just fall under the "you're doing it wrong" category?

I'm trying to setup browser testing and would like to put the test classes into a different folder than ./tests/Browser. Seems like Laravel doesn't find them or doesn't try to run them.

./tests/Browser/InviteRequestTest.php works fine.

./tests/Invitation/Browser/InviteRequestTest.php does not.

No tests executed.

0 likes
2 replies
staudenmeir's avatar

Copy vendor/laravel/dusk/stubs/phpunit.xml as phpunit.dusk.xml to your project directory and replace ./tests/Browser with your custom path.

Add this to tests/DuskTestCase.php (: void is required in Laravel 5.8):

/**
 * Register the base URL with Dusk.
 *
 * @return void
 */
protected function setUp() /*: void*/
{
    parent::setUp();

    Browser::$storeScreenshotsAt = base_path('tests/YourPath/screenshots');

    Browser::$storeConsoleLogAt = base_path('tests/YourPath/console');
}
1 like
bobwurtz's avatar

@staudenmeir This was very helpful! Thank you! For anyone looking to use multiple folders for browser tests, do the following:

<testsuites>
        <testsuite name="Browser Test Suite">
            <directory suffix="Test.php">./tests/Browser</directory>
        </testsuite>
        <testsuite name="Browser Test Suite">
            <directory suffix="Test.php">./tests/Browser/SubDir</directory>
        </testsuite>
    </testsuites>

Please or to participate in this conversation.