Route Validator rules ignored during HTTP tests

Hi guys,

The rules defined in my Validator are being ignored during HTTP tests, but work perfectly using e.g. Postman.

Quick note upfront: I just started using adonis 4.1.

Code:

// routes.js
Route
  .post('auth/login', 'AuthController.login')
  .middleware('guest')
  .validator('Auth/Login')

// Auth/Login.js
  get rules () {
    return {
      username: 'required',
      password: 'required'
    }
  }

// auth.spec.js test
const { test, trait } = use('Test/Suite')('Auth')

const response = await client
    .post('auth/login')
    .send({
      username: user.username,
    })
    .end()

What am I doing wrong?
Thanks :slight_smile:

1 Like

Try to set request content type to json
https://adonisjs.com/docs/4.1/api-tests#_typetype

What is your response returning if you inspect / log it out?

1 Like

pay attention if you are sending a user even in this:
user.username
it may be that it is not correct, if it is an app try to personalize the messages is easier to identify.

1 Like