0

When i try to validate controller response using one of the available assertions like assertJsonValidationErrors it gives the following error:

Failed to find a validation error in the response for key: 'name'

Here is my test:

Mesh::factory()->create(['name'=>'test']);
$this->post(route('meshes.store', ['name' => 'test']));
$this->response->assertUnprocessable()->assertJsonValidationErrors('name');
Pezhvak
  • 9,633
  • 7
  • 29
  • 39

1 Answers1

0

Validation response format in Lumen is different than Laravel which wraps the errors in errors property.

Simply pass null to the second parameter of assertJsonValidationErrors or any other methods available for validation assertion which has this parameter and you should be fine:

$this->response->assertUnprocessable()->assertJsonValidationErrors('name', null);
Pezhvak
  • 9,633
  • 7
  • 29
  • 39