I am trying to test my Ionic app with Jest instead of the traditional Jasmine and Karma. I can run simple test like
expect(1).toEqual(1)
and test passed with no problem.
The issue that I am having is testing services. I have something like
expect(CalculatorService).toBeDefined();
and test will result as passed indicating the service is defined. However when I tried to invoke the method of CalculatorService
expect(CalculatorService.add(1,1).toEqual(2)
results in
"TypeError: CalculatorService.add is not a function"
I know with Jasmine & Karma we need to inject the service. But I don't know what's the equivalent for Jest.
Can someone shed some light?
Aucun commentaire:
Enregistrer un commentaire