How to test validation errors throw exact error and message in laravel unit tests

assertSessionHasErrors can receive an array, as documented:

    'field' => 'Field error message.'

Got the answer

    $errors = session('errors');
    $this->assertEquals($errors->get('name')[0],"Your error message for validation");

$errors is MessageBag object which stored in laravel session when validation error thrown using $errors->get('name') you could see all the validation errors as an array

You may use the combination of assertStatus and assertJson

     'errors' => [
          'field' => [
               'Error message'