0

I am trying to implement e2e tests for my controller but can't get HttpService work. I am importing HttpModule into test module but it didn't see it.

Code: `

    const module = await Test.createTestingModule({
      imports: [HttpModule],
      controllers: [AuthenticationController],
      providers: [
        UsersService,
        AuthenticationService,
        {
          provide: getModelToken(User.name),
          useValue: usersRepository,
        },
      ],
    }).compile();

`

Error:

    Nest can't resolve dependencies of the HttpService (?). Please make sure that the argument AXIOS_INSTANCE_TOKEN at index [0] is available in the RootTestModule context.

    Potential solutions:
    - If AXIOS_INSTANCE_TOKEN is a provider, is it part of the current RootTestModule?
    - If AXIOS_INSTANCE_TOKEN is exported from a separate @Module, is that module imported within RootTestModule?
      @Module({
        imports: [ /* the Module containing AXIOS_INSTANCE_TOKEN */ ]
      })

Maybe someone solved such error before and can advice something? Thanks.

I've tried to find some solution on the internet but found nothing

1 Answers1

0

For some reason it started to work when I'd inject it like so:

{
  provide: HttpService,
  useValue: new HttpService(),
},
pzaenger
  • 11,381
  • 3
  • 45
  • 46