When describing a unit test we do the following:
describe('Some definition', function () {
// ... unit tests
}
Before each test we may want to inject dependencies for all specs, however there are two ways to do this. What is the difference between using angular.mock.inject() and just inject() in a beforeEach()?
beforeEach(angular.mock.inject(function ($injector) {
someService = $injector.get('someService');
}));
and
beforeEach(inject(function ($injector) {
someService = $injector.get('someService');
}));
Thanks :)
inject() is just a shortcut to angular.mock.inject().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With