How to test Laravel Nova Api route policies | TDD
How can I test API route policies for Nova resources?
When I run the following test I receive a 403 response. (without any policies set)
$response = $this->json('POST', 'nova-api/users', [
'name' => 'Fancy Name',
'password' => 'secretpassword',
'email' => '[email protected]'
]);
$response
->assertStatus(200)
->assertJson([
'created' => true,
]);
Hi, I find this repo/nova testing guide very helpful: https://github.com/bradenkeith/testing-nova.
You could setUp() your test with $this->user->assignRole('the_role_you_want_to_test'); and then go on testing your resources and policies.
(I stumbled upon this issue because I myself am stuck with a 404 response testing the nova api routes)
Please or to participate in this conversation.