vendredi 8 septembre 2017

Testing HTML5 Validation with Laravel Dusk

I am creating a simple test inside Laravel Dusk that a user cannot register when leaving the email field blank. The test code is below:

    /** @test */
    public function a_user_cannot_register_without_filling_in_email_field()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/register')
                ->type('password', $this->user->password)
                ->type('password_confirmation', $this->user->password)
                ->press('Register')
                ->assertSee('The email field is required.');
        });
    }

When the required attribute is removed from the form input this test passes, but when it is added the test fails.

Is there another way to test this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire