Closed mitchogaard closed 8 years ago
It looks like you weren't injecting $httpBackend
properly. Because of the way quickmock works, you can't use the typical global inject()
function. You have to use quickmock's inject method, as shown in an updated version of your plunker here and in this snippet below:
service = quickmock({
providerName: 'Service',
moduleName: 'services',
mockModules: ['mocks'],
inject: function(_$httpBackend_){
$httpBackend = _$httpBackend_;
}
});
Hope that helps. If it does, feel free to close out this issue. If not, let me know and I'll revisit the issue.
Holy crap that's very useful information. I don't recall seeing that in the docs anywhere. Can we get an update somewhere that includes why this is or at least an example such as the one you provided? Thank you very much.
@mitchogaard Just FYI, I added this info to the README. Sorry that there previously wasn't any documentation for this feature.
I've got a Plunkr here that shows an issue with trying to use $httpBackend inside of a test and a service (named Service)that uses $http that I'm trying to quickmock. QuickMock doesn't seem to handle the mocking/providing of $http properly. That is, assuming I'm doing everything properly here: https://plnkr.co/edit/1ZxwT8KoZAVcqOiuJDDB?p=preview
Note that the only test where QuickMock does not provide Service passes.