You make a GET and expect to see validation errors?
Nov 16, 2020
7
Level 13
errors are available in view but not in test assertion
I'm using a custom validation and if the validation fails i return a view with the errors
validator = Validator::make(
$request->input(),
$this->rules($request),
$this->messages()
);
if ($validator->fails()) {
return view('some-view')
->withErrors($validator);
}
The issue that i have is that even though in the view i do have access to the errors
@if($errors->any())
@foreach($errors->all() as $error)
{{ $error }}
@endforeach
@endif
When i try to assert that the session has errors, it fails.
$this->get('path')->assertSessionHasErrors('error-name');
but if i assert that the error message is being displayed in the view, it works. And indeed the errors are being displayed when i use the browser.
$this->get('path')->assertSee('error message');
Any thoughts on what i might be doing wrong ?
Please or to participate in this conversation.