This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Description
Is there anyway to get an instance of a specific provider in unit tests to test it?
I'm currently writing a custom provider and want to test it through unit tests, but there seems to be no way to that.
You can do this to configure a provider in unit tests:
...
it('spec', function () {
module(function ($providerInstance) {
$providerInstance.any():
}));
});
...
Or pass module() directly as callback:
...
it('spec', module(function ($providerInstance) {
$providerInstance.any():
})));
...
But then you're not in the right scope to use your test frameworks test methods. So this:
...
it('spec', module(function ($providerInstance) {
$providerInstance.any():
expect(true).toBe(false);
})));
...
Will always pass successfully.
So is there any way (maybe with angular.mocks) to get access to a provider instance in unit tests? Or shouldn't one be able to test providers, cause in code you actually deal with service instances?