-
Notifications
You must be signed in to change notification settings - Fork 27.4k
ngMock fails at $componentController after update from 1.4.8 to 1.5.0 #13969
Comments
Yes, I think you are right. I'll fix it. |
Interesting that our tests didn't catch this 😕 |
It is because our unit tests for |
I take that back. We do use the injector.... not sure why this doesn't fail in our unit tests then... |
This is weird. We do indeed instantiate the So in the injector we have these lines: function provider(name, provider_) {
assertNotHasOwnProperty(name, 'service');
if (isFunction(provider_) || isArray(provider_)) {
provider_ = providerInjector.instantiate(provider_);
}
if (!provider_.$get) {
throw $injectorMinErr('pget', "Provider '{0}' must define $get factory method.", name);
}
return providerCache[name + providerSuffix] = provider_;
} So you can see that we are "instantiating the function that is passed. We ought to be able to have the constructor return an object and that be used instead. I wonder if this is some browser/jsdom specific thing where instantiating in that environment does not work with a constructor returning an object? @ctaepper can you confirm how you are running the tests? |
But I guess we can change it for consistency anyway |
…r constructor function Closes angular#13969
…der constructor function Closes angular#13969
@petebacondarwin sorry for late response! yes i do my tests exactly like that. i pinned it down to PhantomJS. I was using 1.9.x, which apparently can't handle it (did before with ng 1.4.8). I switched to 2.1.x and everything works fine. |
i have no idea whats up?
FYI: tests are also working in 1.4.9
after some digging:
https://github.com/angular/angular.js/blob/v1.5.0/src/ngMock/angular-mocks.js#L2186
shouldn't this read
this.$get = ....
? after fixing that in the dist file, the tests are workingalso, to clarify, I am running tests on module, which only consists of services and factories
The text was updated successfully, but these errors were encountered: