.l-main-section
h2(class="function export") inject
p (tokens: List, fn: Function)
p(class="module").
exported from angular2/test
:markdown
Allows injecting dependencies in `beforeEach()` and `it()`.
Example:
```
beforeEach(inject([Dependency, AClass], (dep, object) => {
// some code that uses `dep` and `object`
// ...
}));
it('...', inject([AClass, AsyncTestCompleter], (object, async) => {
object.doSomething().then(() => {
expect(...);
async.done();
});
})
```
Notes:
- injecting an `AsyncTestCompleter` allow completing async tests - this is the equivalent of
adding a `done` parameter in Jasmine,
- inject is currently a function because of some Traceur limitation the syntax should eventually
becomes `it('...', @Inject (object: AClass, async: AsyncTestCompleter) => { ... });`