diff --git a/packages/core/testing/src/r3_test_bed.ts b/packages/core/testing/src/r3_test_bed.ts index 32080dbff3..5eec6ba78e 100644 --- a/packages/core/testing/src/r3_test_bed.ts +++ b/packages/core/testing/src/r3_test_bed.ts @@ -65,6 +65,8 @@ let _nextRootElementId = 0; const EMPTY_ARRAY: Type[] = []; +const UNDEFINED: Symbol = Symbol('UNDEFINED'); + // Resolvers for Angular decorators type Resolvers = { module: Resolver, @@ -311,6 +313,7 @@ export class TestBedRender3 implements Injector, TestBed { // reset test module config this._providers = []; this._compilerOptions = []; + this._compilerProviders = []; this._declarations = []; this._imports = []; this._schemas = []; @@ -405,7 +408,8 @@ export class TestBedRender3 implements Injector, TestBed { if (token === TestBedRender3) { return this; } - return this._moduleRef.injector.get(token, notFoundValue); + const result = this._moduleRef.injector.get(token, UNDEFINED); + return result === UNDEFINED ? this.compilerInjector.get(token, notFoundValue) : result; } execute(tokens: any[], fn: Function, context?: any): any { @@ -590,8 +594,8 @@ export class TestBedRender3 implements Injector, TestBed { } get compilerInjector(): Injector { - if (this._compilerInjector !== undefined) { - this._compilerInjector; + if (this._compilerInjector !== null) { + return this._compilerInjector; } const providers: StaticProvider[] = []; diff --git a/packages/platform-browser-dynamic/test/testing_public_browser_spec.ts b/packages/platform-browser-dynamic/test/testing_public_browser_spec.ts index 246ec76df2..14091e7d79 100644 --- a/packages/platform-browser-dynamic/test/testing_public_browser_spec.ts +++ b/packages/platform-browser-dynamic/test/testing_public_browser_spec.ts @@ -63,11 +63,10 @@ if (isBrowser) { {providers: [{provide: FancyService, useValue: new FancyService()}]}); }); - fixmeIvy('FW-919: TestBed.get should be able to retrieve tokens from Compiler\'s injector') - .it('provides a real ResourceLoader instance', - inject([ResourceLoader], (resourceLoader: ResourceLoader) => { - expect(resourceLoader instanceof ResourceLoaderImpl).toBeTruthy(); - })); + it('provides a real ResourceLoader instance', + inject([ResourceLoader], (resourceLoader: ResourceLoader) => { + expect(resourceLoader instanceof ResourceLoaderImpl).toBeTruthy(); + })); it('should allow the use of fakeAsync', fakeAsync(inject([FancyService], (service: any /** TODO #9100 */) => {