Мой контроллер имеет аргумент InjectModel, код:
constructor(
@InjectModel(Poll) private readonly model: ReturnModelType<typeof Poll>,
){
}
, а код опроса:
import { prop, modelOptions, getModelForClass } from '@typegoose/typegoose';
import { ApiProperty, ApiPropertyOptions } from '@nestjs/swagger';
@modelOptions({
schemaOptions: {
timestamps: true
}
})
export class Poll {
@ApiProperty({
})
@prop({required: true})
title: string
@prop({required: true})
description: string
@prop()
poll: number
@prop({select: false})
userId: string
@prop()
userName: string
}
Код Jest:
import { Poll } from '@libs/db/models/poll.model';
const module: TestingModule = await Test.createTestingModule({
imports: [PollsModule],
controllers: [PollsController],
providers: [
{
provide: getModelForClass(Poll),
useValue: getModelForClass(Poll)
},
]
}).compile();
и я получаю эту ошибку: Nest не может разрешить зависимости ОпросыController (?). Пожалуйста, убедитесь, что аргумент PollModel в index [0] доступен в контексте ОпросыModule.
Potential solutions:
- If PollModel is a provider, is it part of the current PollsModule?
- If PollModel is exported from a separate @Module, is that module imported within PollsModule?
@Module({
imports: [ /* the Module containing PollModel */ ]
})