Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Jasmine, What is the difference between angular.mock.inject and inject?

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 :)

like image 679
Simon Willan Avatar asked Apr 10 '26 22:04

Simon Willan


1 Answers

inject() is just a shortcut to angular.mock.inject().

like image 144
Shalom Peles Avatar answered Apr 12 '26 10:04

Shalom Peles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!