Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

akogler's avatar

Laravel dusk reports "General error: 5 database is locked" and "Operation timed out"

Hi to all,

I am running the script

namespace Tests\Browser;
    
use App\User;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\RefreshDatabase;

class RegistrationTest extends DuskTestCase
{

    use RefreshDatabase;

    /** @test */
   public function a_user_registers_for_an_account()
   {
        $this->browse(function (Browser $browser)
        {
            $browser->visit(route('app-registration-create'))
                ->type('name', 'John')
                ->type('lastName', 'Doe')
                ->type('email', '[email protected]')
                ->type('password', 'password')
                ->type('password_confirmation', 'password')
                ->click('@dusk-accept')
                ->click('@register-button') //
                ->assertDontSee('The name field is required.');
        });
    
        $this->assertDatabaseHas('users', [
            'email' => '[email protected]',
            'verified' => 0
        ]);
    }
    
    
    /** @test */    
    public function a_user_confirms_a_email_address()
    {
        $this->browse(function (Browser $browser)
        {
            $user = User::where('email', '[email protected]')->first();

            var_dump(route('app-registration-confirm-email', ['token' => $user->token])); // "http://ps.dev/app/registration/confirm/aPAWN1QlGyl8Id2vXIJU9Fn8G6bsef"

            $browser->visit(route('app-registration-confirm-email', ['token' => $user->token]));

        });
    
        $this->assertDatabaseHas('users', [
            'email' => '[email protected]',
           'verified' => 1
       ]);
   }

}

and when it hits the line

$browser->visit(route('app-registration-confirm-email', ['token' => $user->token]));

it stops working. The idea behind that step is to verify that the user provided a valid e-mail address. Therefore the application will grab the token from the URL and check if there is a user in the database with that token. If so, set in the database for the matching record the verified property to 1 and the token to null.

But I get the following errors:

Inside the laravel.log file I can see:

[2017-10-17 13:24:30] testing.ERROR: SQLSTATE[HY000]: General error: 5 
database is locked (SQL: update "users" set "verified" = 1, "token" = , 
"updated_at" = 2017-10-17 13:23:30 where "id" = 1)

On the terminal I can see:

There was 1 error:

1) Tests\Browser\RegistrationTest::a_user_confirms_a_email_address
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http GET to /session/856dbb7e7769ec0a369e44e13b6b676d/screenshot

Operation timed out after 30000 milliseconds with 0 bytes received

/home/vagrant/ps/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:286    /home/vagrant/ps/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:535    /home/vagrant/ps/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:333
/home/vagrant/ps/vendor/laravel/dusk/src/Browser.php:244
/home/vagrant/ps/vendor/laravel/dusk/src/TestCase.php:160    /home/vagrant/ps/vendor/laravel/framework/src/Illuminate/Support/Collection.php:341
/home/vagrant/ps/vendor/laravel/dusk/src/TestCase.php:161
/home/vagrant/ps/vendor/laravel/dusk/src/TestCase.php:94
/home/vagrant/ps/tests/Browser/RegistrationTest.php:51

I'm new to Dusk, so maybe I don't apply dusk properly.

0 likes
0 replies

Please or to participate in this conversation.