fix(testing): add an explicit doAsyncPrecompilation step (#10015)

This removes the magic from the `inject` test helper that would inspect
the current zone and would only work with our `async` test helper.
Now, `inject` is always synchronous, and if you are using a module
that requires async precompilation, you're required to call
`doAsyncPrecompilation` in your tests.

This is part of the breaking changes introduced with the swap
to each test having an AppModule.

Closes #9975
Closes #9593

BREAKING CHANGE:

`TestInjector` is now renamed to `TestBed`

Before:

```js
import {TestInjector, getTestInjector} from '@angular/core/testing';
```

After:

```js
import {TestBed, getTestBed} from '@angular/core/testing';
```
This commit is contained in:
Julie Ralph
2016-07-20 10:51:21 -07:00
committed by GitHub
parent 450f61d384
commit b43f95435b
10 changed files with 172 additions and 138 deletions

View File

@ -7,7 +7,7 @@
*/
import {beforeEach, ddescribe, xdescribe, describe, expect, iit, inject, beforeEachProviders, it, xit,} from '@angular/core/testing/testing_internal';
import {TestComponentBuilder, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone} from '@angular/core/testing';
import {TestComponentBuilder, ComponentFixtureAutoDetect, ComponentFixtureNoNgZone, withProviders} from '@angular/core/testing';
import {AsyncTestCompleter} from '@angular/core/testing/testing_internal';
import {Injectable, Component, Input, ViewMetadata} from '@angular/core';
import {NgIf} from '@angular/common';
@ -15,7 +15,6 @@ import {TimerWrapper} from '../src/facade/async';
import {IS_DART} from '../src/facade/lang';
import {PromiseWrapper} from '../src/facade/promise';
import {dispatchEvent} from '@angular/platform-browser/testing/browser_util';
import {withProviders} from '@angular/core/testing/test_injector';
@Component(
{selector: 'child-comp', template: `<span>Original {{childBinding}}</span>`, directives: []})

View File

@ -7,12 +7,13 @@
*/
import {AnimationEntryMetadata, Compiler, ComponentFactory, Inject, Injectable, Injector, NgZone, ViewMetadata} from '@angular/core';
import {ComponentFixture, ComponentFixtureNoNgZone, TestComponentBuilder, TestInjector} from '@angular/core/testing';
import {ComponentFixture, ComponentFixtureNoNgZone, TestBed, TestComponentBuilder} from '@angular/core/testing';
import {DirectiveResolver, ViewResolver} from '../index';
import {MapWrapper} from '../src/facade/collection';
import {ConcreteType, IS_DART, Type, isPresent} from '../src/facade/lang';
/**
* A TestComponentBuilder that allows overriding based on the compiler.
*/
@ -31,7 +32,7 @@ export class OverridingTestComponentBuilder extends TestComponentBuilder {
/** @internal */
_viewOverrides = new Map<Type, ViewMetadata>();
constructor(@Inject(TestInjector) injector: Injector) { super(injector); }
constructor(@Inject(TestBed) injector: Injector) { super(injector); }
/** @internal */
_clone(): OverridingTestComponentBuilder {