Laravel 5.7 dusk login testing fails with wrong credentials

Posted 9 months ago by ThePoet444

I am writing code to transition users from our current php crypt(), to bcrypt. Which according to other tests i've written, seems to work. So now I'm checking the front end and started to write tests for Dusk finally. Following the example in the (Laravel Docs)[https://laravel.com/docs/master/dusk#getting-started] it keeps failing and giving me a screenshot with the error of "These credentials do not match our records". Which makes sense since the DB is empty... but when using DB Migrations and a user factory set to create.. you would think it should pass then. Anyone know where I goofed? the User factory is the same from the docs.

LoginTest:

<?php

namespace Tests\Browser;

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

class LoginTest extends DuskTestCase
{
    use DatabaseMigrations;

    /**
     * A basic browser test example.
     *
     * @return void
     */

    /** @test */
    public function a_users_pass_will_convert_from_current_rs_hash_to_new_hash()
    {
        $user = factory(User::class)->create();

        $this->browse(function ($browser) use ($user) {
            $browser->visit('/login')
                ->type('email', $user->email)
                ->type('password', 'secret')
                ->press('Login')
                ->assertPathIs('/')
                ->assertSee('Logout');
        });

        $this->assertTrue(Hash::check('secret', $user->password));
    }
}


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

Reply to

Use Markdown with GitHub-flavored code blocks.