I have to unit test some service without installing any third party packages like "Automock" or "golevelup" packages.
// myService.service.ts
export class MyService {
constructor(private readonly getDataApi: GetDataApi) {}
async getDataApi(params: MyParams): Promise<Data | null> {
this.getDataApi.execute({ ...params });
}
}
// get-data-api.ts
export class GetDataApi {
constructor(private readonly configService: ConfigService, private readonly httpService: IHttpService){}
async execute() {
const config: HttpServiceRequestConfig = {
// ...some config
}
// make a GET request and return data
await httpService.request<Data>(config);
}
}
Any idea how to unit test myService with mocking all this dependencies?