我正在尝试为我的控制器实现e2e测试,但无法使HttpService工作。我正在将HttpModule导入测试模块,但它没有看到它。
代码:
const module = await Test.createTestingModule({
imports: [HttpModule],
controllers: [AuthenticationController],
providers: [
UsersService,
AuthenticationService,
{
provide: getModelToken(User.name),
useValue: usersRepository,
},
],
}).compile();
`
错误:
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 */ ]
})
也许以前有人解决过这样的错误,可以给点建议吗?谢谢。
我试着在网上找一些解决办法,但一无所获
1条答案
按热度按时间atmip9wb1#
不知道为什么,当我这样注射时,它就开始起作用了: