cristimocean
3 months ago
360
4
Laravel

Dusk runs web.php multiple times

Posted 3 months ago by cristimocean

I am just learning Dusk, and I have a problem: I cannot run more than one test at a time. If I try to run 2 tests I get an error about const version being already defined in web.php. How can I run 2 tests and bypass this error ?

I run this with php artisan dusk --group setup

Here's my code:

<?php

namespace Tests\Browser;

use App\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;

class SetupTest extends DuskTestCase
{
    use DatabaseMigrations;

    public function setUp():void
    {
        parent::setUp();

        $this->seed();
    }

    /** @test
     * @group can_login
     * @group setup
     */
    public function can_login()
    {
        $this->browse(function (Browser $browser) {
            $member = factory(User::class)->create();
            $browser->loginAs($member)
                ->visit('/home')
                ->assertPathIs('/tasks');
        });
    }

    /**
     * @test
     * @group can_connect_to_database
     * @group setup
     */
    public function can_connect_to_database()
    {
        DB::statement('CREATE TABLE dummy (id int, name varchar(255))');
        $data = ['id' => 1, 'name' => 'lalala'];
        DB::table('dummy')->insert($data);
        $this->assertDatabaseHas('dummy', ['name' => 'lalala']);
    }

}

Please sign in or create an account to participate in this conversation.