Hi, I'm trying to mock few dependencies of a service that i'm testing.
the dependencies as the constructor shows are:
export class CropStrainService extends GenericEntityService <CropStrain, CropValidator> {
constructor(
@InjectRepository(CropStrain)
protected cropStrainRepository: Repository<CropStrain>,
@Inject(CropsConnectionService) private cropsConnectionService: CropsConnectionService
){
super(cropStrainRepository);
this.validator=new CropValidator(this);
}
i've tried mocking the dependencies as shown here:
describe("CropType Service", () => {
let cropTypeService: CropTypeService;
const mockRepository = {};
const mockConnectionService = {
getStrainsByProject: jest.fn(projectId=>[{id:1,name:"harvesting",Crop:[],strains:[]}])
};
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [
CropTypeService,
{
provide: getRepositoryToken(CropType),
useValue: mockRepository
},
{
provide: CropsConnectionService,
useValue: mockConnectionService
}
],
}).compile();
cropTypeService = module.get<CropTypeService>(CropTypeService);
});
but the compiler doesn't read my mockings. what should be the right way to mock those dependencies?