tsaicharlie93's avatar

Trying to do a Login test from browser test

I am trying to use login test from browser testing.

Here is my code:

    $this->browse(function (Browser $browser) {
        $browser->visit('/login')
                ->clear('email')
                ->clear('password')
                ->type('email', 'test123@gmail.com')
                ->type('password', 'password')
                ->press('Login')
                ->pause(5000)
                ->assertPathIs('/home');
    });

my route is

Auth::routes();

I am trying to see if the page redirects to the home page after login, but I keep getting a saying

Failed asserting that '/login' matches PCRE pattern "/^/home/u".

Is it because the page is not redirecting after login?

0 likes
2 replies
andonovn's avatar
andonovn
Best Answer
Level 22

@tsaicharlie93 yes, it's because the redirect didn't happen. Most probably because there was no user with the given credentials.

PS When Dusk test is failing, there would be a screenshot for you in the tests/Browser/screenshots/ directory. Sometimes that's very useful.

Please or to participate in this conversation.