<p dir="auto">This happens both locally and on <a href="https://travis-ci.org/angular/angular/jobs/62268311" rel="nofollow">Travis</a>.</p>
<p dir="auto">You get something like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="...
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 125 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 134 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 128 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 211 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 121 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 120 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 124 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 125 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 125 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 121 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 129 μs
[13:53:13] Starting 'cleanup.builder'...
..."><pre class="notranslate"><code class="notranslate">...
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 125 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 134 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 128 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 211 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 121 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 120 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 124 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 125 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 125 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 121 μs
[13:53:13] Starting 'cleanup.builder'...
[13:53:13] Finished 'cleanup.builder' after 129 μs
[13:53:13] Starting 'cleanup.builder'...
...
</code></pre></div>
<ul class="contains-task-list">
<li><strong>I'm submitting a ...</strong></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> bug report</li>
</ul>
<p dir="auto"><strong>Current behavior</strong><br>
I'm using ComponentResolver to render dynamically 'some'(all names - just alias) component to custom selector on a body.<br>
Like that:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="class SomeClass {
    constructor(private resolver:ComponentResolver, private injector:Injector, private appRef:ApplicationRef) {
    }

    public renderComponent() {
        return this.resolver
            .resolveComponent(SomeComponent)
            .then((factory:ComponentFactory&lt;SomeComponent&gt;) =&gt; {
                let cmpRef:ComponentRef&lt;SomeComponent&gt; = factory.create(this.injector, null, `.some-class`);
                (&lt;any&gt;this.appRef)._loadComponent(cmpRef);
                return cmpRef;
            });
    }
}"><pre class="notranslate"><code class="notranslate">class SomeClass {
    constructor(private resolver:ComponentResolver, private injector:Injector, private appRef:ApplicationRef) {
    }

    public renderComponent() {
        return this.resolver
            .resolveComponent(SomeComponent)
            .then((factory:ComponentFactory&lt;SomeComponent&gt;) =&gt; {
                let cmpRef:ComponentRef&lt;SomeComponent&gt; = factory.create(this.injector, null, `.some-class`);
                (&lt;any&gt;this.appRef)._loadComponent(cmpRef);
                return cmpRef;
            });
    }
}
</code></pre></div>
<p dir="auto">This works for application itself. But when I try to test it (Jasmine 2.4 and Karma, Webpack for test build):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import {it, inject, describe, expect, beforeEach, beforeEachProviders, fakeAsync, tick} from '@angular/core/testing';
import {ComponentResolver, Injector, ApplicationRef, provide} from '@angular/core';
import {ReflectorComponentResolver} from '@angular/core/src/linker/component_resolver';
import {SomeClass} from './some-class';

describe('SomeClass', () =&gt; {
    let someClassInstance:SomeClass;
    let resolver:ComponentResolver;

    beforeEachProviders(() =&gt; [
        provide(ComponentResolver, {
            useClass: ReflectorComponentResolver
        }), 
        Injector,
        ApplicationRef,
        SomeClass
    ]);

    beforeEach(inject([ComponentResolver, SomeClass],
        (cmpRes:ComponentResolver, someClass:SomeClass) =&gt; {
            resolver = cmpRes;
            someClassInstance = someClass;
        }));

    it('renderComponent method should render component', fakeAsync(() =&gt; {
        spyOn(resolver, 'resolveComponent').and.callThrough();
        someClassInstance.renderComponent();
        tick();

        expect(resolver.resolveComponent).toHaveBeenCalled();
    }));
});"><pre class="notranslate"><code class="notranslate">import {it, inject, describe, expect, beforeEach, beforeEachProviders, fakeAsync, tick} from '@angular/core/testing';
import {ComponentResolver, Injector, ApplicationRef, provide} from '@angular/core';
import {ReflectorComponentResolver} from '@angular/core/src/linker/component_resolver';
import {SomeClass} from './some-class';

describe('SomeClass', () =&gt; {
    let someClassInstance:SomeClass;
    let resolver:ComponentResolver;

    beforeEachProviders(() =&gt; [
        provide(ComponentResolver, {
            useClass: ReflectorComponentResolver
        }), 
        Injector,
        ApplicationRef,
        SomeClass
    ]);

    beforeEach(inject([ComponentResolver, SomeClass],
        (cmpRes:ComponentResolver, someClass:SomeClass) =&gt; {
            resolver = cmpRes;
            someClassInstance = someClass;
        }));

    it('renderComponent method should render component', fakeAsync(() =&gt; {
        spyOn(resolver, 'resolveComponent').and.callThrough();
        someClassInstance.renderComponent();
        tick();

        expect(resolver.resolveComponent).toHaveBeenCalled();
    }));
});
</code></pre></div>
<p dir="auto">ReflectorComponentResolver(I'm using it, because ComponentResolver is just an abstract class) throws an exception:<br>
<code class="notranslate">Error: No precompiled component SomeComponent found</code><br>
And for sure promise is never resolved.</p>
<p dir="auto"><strong>Expected/desired behavior</strong><br>
I would like ComponentResolver(or any inherited class) to resolve component in unit tests. Or it would be great to provide any documentation - how to avoid it, if this behavior is expected.</p>
<ul dir="auto">
<li><strong>Angular version:</strong> 2.0.0-rc.1</li>
<li><strong>Browser:</strong> [ PhantomJS2 ]</li>
<li><strong>Language:</strong> [ TypeScript 1.9 ]</li>
</ul>