dimanche 21 octobre 2018

How to get rid of error 422 laravel in a unit test?

So I'm writing unit tests for a laravel 5.7 web app and when I test the login it gives me error 422(I know that it has something to do with invalid data, I just don't know how to fix it)

public function testRegularUserLogin_CreatedRegularUse_ReturnsStoreView()
{
    $regularUser = factory( User::class)->create();

    $response = $this->json('POST','/login',
        [
            'email' => $regularUser->email,
            'password' => $regularUser->password,
            '_token' => csrf_token()
        ]);


    $response->assertStatus(200);


}

I've tried using the csrf token on the header



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire