Summer Sale! All accounts are 50% off this week.

bbkbbk's avatar

Laravel Dusk - error after using DatabaseMigrations

I am trying to use Dusk for my app but have encountered an issue when running my first custom Dusk test. I am using the documentation as a reference for getting Dusk working:

https://laravel.com/docs/9.x/dusk

First thing I done was: composer require --dev laravel/dusk

Second: php artisan dusk:install

For the environment I've created a separate database and am using an .env.dusk.local file

So far on my app I've set up Laravel Fortify for authentication and have created the registration page view and set the default page to go to '/account' on success. I have wrote a feature test for this which works and if I do the same steps that I'm trying to simulate in Dusk on my Web Browser it works as expected.

Here is my Dusk test code:

    $this->browse(function (Browser $browser) {
        $browser->visit('/register')
                ->assertSee('Register')
                ->type('name', 'Example Name')
                ->type('email', '[email protected]')
                ->type('password', 'password')
                ->type('password_confirmation', 'password')
                ->press('Register')
                ->assertPathIs('/account');
    });

I'm also using: use DatabaseMigrations;

Essentially what I'm trying to test is someone goes to the registration page, fills out the registration form with valid inputs which populates the users table and redirects the user to their 'account' page.

If I go into the DuskTestCase.php file and comment out '--headless', I can see what happens in the browser, as soon as "Register" is clicked a 404 popup occurs (where I expect it to go to '/account'). The user table in the database has this record inserted with the correct information (I'm not sure but thought the record would be deleted after the test has run). If I check the terminal I'm getting this error:

BadMethodCallException: Method Illuminate\Database\Schema\Blueprint::dropColum does not exist.

I'm not sure the next steps to debug this so any help is much appreciated, thanks.

0 likes
2 replies
willvincent's avatar

dropColum seems to be missing its last character, n... should be dropColumn

Typo in a migration file..?

bbkbbk's avatar

@willvincent Thank you I missed that! I've got that error resolved now but the redirect at the end isn't working. The "assertPathIs" failing expecting to assert that the page is "/register" but it should be "/account". It redirects correctly to the account page if I do the test manually in my browser. I've tried using a timed pause and "waitForLocation" but after 5 seconds it will fail the test as it doesn't go to "/account". Any idea what could be wrong? (I'm using Inertia & Vue3 if that makes a difference)

Please or to participate in this conversation.