Testing - TypeError: client.get(...).loginVia is not a function


#1

When I make client.post().loginVia(), it works fine.

But with .get() method i get this error:

ERRORS

  1. Should query clinics if authenticated
  TypeError: client.get(...).loginVia is not a function
    at Callable.test [as _fn] (C:\Users\Usuario\Downloads\Rafael\Dev\odontopay\server\test\functional\clinic.spec.js:26:6)
    at <anonymous>
// clinic.spec.js

'use strict'
const User = use('App/Models/User')

const { test, trait } = use('Test/Suite')('Clinic')

trait('Test/ApiClient')

test('Should not query any clinic if not authenticated', async ({ client }) => {
  const response = await client.get('/api/v1/clinics/').end()

  response.assertStatus(401)
})

test('Should query clinics if authenticated', async ({ client }) => {
  const data = {
    name: 'Query',
    surname: 'Clinics',
    email: 'queryclinics@gmail.com',
    password: 'secret'
  }
  
  const user = await User.create(data)

  const response = await client
    .get('/api/v1/clinics/')
    .loginVia(user)
    .end()

  response.assertStatus(200)
})

#2

#SOLVED.

I forgot to add:

trait('Auth/Client')