A
A
AleDv2018-06-22 11:39:26
Software testing
AleDv, 2018-06-22 11:39:26

How to correctly run multiple Laravel Dusk tests?

There is one class in which authorization on the site is tested:

class LoginTest extends DuskTestCase
{

    /**
     * Тестируем авторизацию на сайте c корректными данными
     *
     * @return void
     * @throws \Throwable
     */
    public function testTrueLogin()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/login')
                    ->type('email', '[email protected]')
                    ->type('password', '123456')
                    ->press('Войти')
                    ->assertPathIs('/cabinet')
                    ->quit();
        });

    }

    /**
     * Тестируем авторизацию на сайте c НЕ корректными данными
     * 
     * @throws \Throwable
     */
    public function testFalseLogin()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/login')
                    ->type('email', '[email protected]')
                ->type('password', '123123')
                ->press('Войти')
                ->assertPathIs('/login');
        });

    }
}

If you run a test with one of the testTrueLogin or testFalseLogin methods, then the tests run correctly. If I leave both tests, I get an error when running the second test:
1) Tests\Browser\LoginTest::testFalseLogin
Failed asserting that '' matches PCRE pattern "/^\/login/u".

If you remove the "--headless" directive in the browser settings, then the browser does not even open for the second test. Tell me, where did I mess up?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question