wardbell / bardjs

Spec helpers for testing angular v.1.x apps with Mocha, Jasmine and QUnit
MIT License
178 stars 34 forks source link

How to test a service with mocked dependencies services #42

Open samih-dev opened 7 years ago

samih-dev commented 7 years ago

Hi Thanks for creating this, really helps..

I'm facing issue when tried to write unit-tests for a service, I need to mock the dependencies services that I need for this service with the help of bard.mockService,

The angular way without bardjs usages listed here: https://docs.angularjs.org/guide/services

For controller testing this wasn't a problem as we can instanciate a controller sending the service map it needs using $controller service.

Is there anyway to do this?

bensinther commented 7 years ago

@samih-dev - I have faced a similar issue here: https://github.com/wardbell/bardjs/issues/36. See section "UPDATE 19.05.2016" - this way you should be able to mock your dependencies.