我想测试我的服务(位置服务)。在此位置服务中,我注入存储库和其他名为 GeoLocationService 的服务,但当我尝试模拟此 GeoLocationService 时陷入困境。
\n它给我一个错误
\nGeolocationService \xe2\x80\xba should be defined\n\n Nest can't resolve dependencies of the GeolocationService (?). Please make sure that the argument HttpService at index [0] is available in the RootTestModule context.\n\nRun Code Online (Sandbox Code Playgroud)\n这是提供商的代码
\n@Injectable()\nexport class LocationService {\n constructor(\n @Inject('LOCATION_REPOSITORY')\n private locationRepository: Repository<Location>,\n\n private geolocationService: GeolocationService, // this is actually what I ma trying to mock\n ) {}\n\n async getAllLocations(): Promise<Object> {\nreturn await this.locationRepository.find()\n }\n....\n}\n\nRun Code Online (Sandbox Code Playgroud)\n这是测试代码
\ndescribe('LocationService', () => {\n let service: …Run Code Online (Sandbox Code Playgroud) 我是新手nest.js,对此有疑问。
我想将多个类扩展Dto到我的主dto类,但我知道不可能扩展超过 2 个dto类。你知道该怎么做吗?
这是我的主要dto课程:
export class CarDto extends PickupLocationDto {
@ApiProperty({ example: 'Aventador', description: 'The car name' })
readonly modelName: string;
}
Run Code Online (Sandbox Code Playgroud)
最近我只能从PickupLocationDto类中扩展它,但我想再扩展一个dto类到这个CarDto类。
任何帮助表示赞赏。