Test passes even when no Controller exists


#1

When using Route.resources(), this:

Route.resource('users', 'UserController')

Eequates to this

Route.get('users', 'UserController.index').as('users.index')
Route.post('users', 'UserController.store').as('users.store')
Route.get('users/create', 'UserController.create').as('users.create')
Route.get('users/:id', 'UserController.show').as('users.show')
Route.put('users/:id', 'UserController.update').as('users.update')
Route.patch('users/:id', 'UserController.update')
Route.get('users/:id/edit', 'UserController.edit').as('users.edit')
Route.delete('users/:id', 'UserController.destroy').as('users.destroy')

What I notice is that there is no generated UserController.js file at all. And it is weird when I test the end points above, the test passes without even having a controller with the above functions in place. Is this normal? What am I missing here?

Thank you,
Billal Begueradj


#2

Hey @begueradj! :wave:

I would need more code to be able to help you.
What is your actual test code?


#3

Thank you for the attention @romain.lanz :slight_smile:

For example this test passes even when I do not have a UserController.js file:

test('Route /users/:id/edit responds to GET', async ( { client } ) => {                                                                                 
  const response = await client.get('/users/edit').end()                                                                            
  response.assertStatus(200)                                                                                                                     
})

#4

If you use Postman to make the same request what response do you get?


#5

Good point @jacksoncharles I had some big mistake that I feel shy to share :smile: