Laravel - HTTP Tests - Assert Session Has Errors

Assert that the session contains an error for the given $keys. If $keys is an associative array, assert that the session contains a specific error message (value) for each field (key). This method should be used when testing routes that flash validation errors to the session instead of returning them as a JSON structure:

        array $keys, $format = null, $errorBag = 'default'

For example, to assert that the name and email fields have validation error messages that were flashed to the session, you may invoke the assertSessionHasErrors method like so:

    $response->assertSessionHasErrors(['name', 'email']);

Or, you may assert that a given field has a particular validation error message:

        'name' => 'The given name was invalid.'