methos's avatar

Laravel Dusk: Timeout with the first test in the Class

Hello, I'm facing a weird issue ... The first test in my class got a timeout, if i duplicate it with "2" in the end of the function name, it's work Oo. My driver and chromer are updated !

<?php

namespace Tests\Browser\Controllers\FollowController;

use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
use Throwable;

class FollowProductToggleTest extends DuskTestCase {

    /**
     * @test
     * @throws Throwable
     */
    public function followProductGuestTest(): void {
        $this->browse(function (Browser $browser) {
            $browser->visit(route('homepage'));
            $browser->assertPresent('#show-login');

            $browser->waitFor('#products-list .product:first-child [data-follow]');
            $browser->script("document.querySelector('#products-list .product:first-child [data-follow]').scrollIntoView({ block: 'center' });");
            $browser->click('#products-list .product:first-child [data-follow]');
            $browser->waitFor('.flash-info');
            $browser->assertPresent('.flash-info.show');
        });
    }

    /**
     * @test
     * @throws Throwable
     */
    public function followProductGuest2Test(): void {
        $this->browse(function (Browser $browser) {
            $browser->visit(route('homepage'));
            $browser->assertPresent('#show-login');

            $browser->waitFor('#products-list .product:first-child [data-follow]');
            $browser->script("document.querySelector('#products-list .product:first-child [data-follow]').scrollIntoView({ block: 'center' });");
            $browser->click('#products-list .product:first-child [data-follow]');
            $browser->waitFor('.flash-info');
            $browser->assertPresent('.flash-info.show');
        });
    }

    /**
     * @test
     * @throws Throwable
     */
    public function followProductUserTest(): void {
        $this->browse(function (Browser $browser) {
            $browser->visit(route('homepage'));
            $browser->assertPresent('#show-login');

            $browser->click('#show-login');
            $browser->waitFor('.side-auth-content.show');

            if($browser->value('input[name="login[email]"]') == "") $browser->keys('input[name="login[email]"]', '[email protected]');
            if($browser->value('input[name="login[password]"]') == "") $browser->keys('input[name="login[password]"]', '1234');
            $browser->press('#form-login_submit');
            $browser->waitUntilMissing('#form-login_submit');

            $browser->waitFor('#products-list .product:first-child [data-follow]');
            $browser->script("document.querySelector('#products-list .product:first-child [data-follow]').scrollIntoView({ block: 'center' });");
            $browser->click('#products-list .product:first-child [data-follow]');
            $browser->waitFor('.flash-success');
            $browser->assertPresent('.flash-success.show');
        });
    }
}

Do you know how can i fixe it ? I don't konw where i should look to give more information to help you ....

0 likes
7 replies
methos's avatar

Hello, Little up,

I should add a fakeTest at the begining of all my test files ^^'

/**
     * @test
     * @throws Throwable
     */
    public function fakeTest(): void {
        $this->browse(function (Browser $browser) {
            $browser->visit(route('homepage'));
            $browser->assertPresent('#show-login');
        });
    }
methos's avatar

I still have this issue ... ='(

methos's avatar

I still have my issue, there is a screenshot. All my dusk Class begin by fakeTest ... screenshot of the issue ERR_TIMED_OUT

methos's avatar

No answer ? Does anyone have a lead ?

methos's avatar

Am I the only one with this problem ?

methos's avatar
Level 1

Arrrgggggghhhhh I finally found the solution. In my laravel dusk configuration, driver function, the headless was '--headless=new' and not '--headless'

If anyone have the problem ...

Please or to participate in this conversation.