diff --git a/packages/core/testing/src/r3_test_bed.ts b/packages/core/testing/src/r3_test_bed.ts index 120f33f5ec..7c7e4cdfdf 100644 --- a/packages/core/testing/src/r3_test_bed.ts +++ b/packages/core/testing/src/r3_test_bed.ts @@ -634,6 +634,11 @@ export class TestBedRender3 implements Injector, TestBed { return Object.keys(overrides).length ? {...meta, ...overrides} : meta; } + /** + * @internal + */ + _getModuleResolver() { return this._resolvers.module; } + /** * @internal */ @@ -764,5 +769,8 @@ class R3TestCompiler implements Compiler { clearCacheFor(type: Type): void {} - getModuleId(moduleType: Type): string|undefined { return undefined; } + getModuleId(moduleType: Type): string|undefined { + const meta = this.testBed._getModuleResolver().resolve(moduleType); + return meta && meta.id || undefined; + } } 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 7c78407d4d..246ec76df2 100644 --- a/packages/platform-browser-dynamic/test/testing_public_browser_spec.ts +++ b/packages/platform-browser-dynamic/test/testing_public_browser_spec.ts @@ -80,20 +80,19 @@ if (isBrowser) { }); describe('Compiler', () => { - fixmeIvy('FW-855: TestBed.get(Compiler) should return TestBed-specific Compiler instance') - .it('should return NgModule id when asked', () => { - @NgModule({ - id: 'test-module', - }) - class TestModule { - } + it('should return NgModule id when asked', () => { + @NgModule({ + id: 'test-module', + }) + class TestModule { + } - TestBed.configureTestingModule({ - imports: [TestModule], - }); - const compiler = TestBed.get(Compiler) as Compiler; - expect(compiler.getModuleId(TestModule)).toBe('test-module'); - }); + TestBed.configureTestingModule({ + imports: [TestModule], + }); + const compiler = TestBed.get(Compiler) as Compiler; + expect(compiler.getModuleId(TestModule)).toBe('test-module'); + }); }); describe('errors', () => { diff --git a/packages/platform-browser/test/testing_public_spec.ts b/packages/platform-browser/test/testing_public_spec.ts index bf25a8b037..c0a52012cb 100644 --- a/packages/platform-browser/test/testing_public_spec.ts +++ b/packages/platform-browser/test/testing_public_spec.ts @@ -457,28 +457,25 @@ class CompWithUrlTemplate { expect(TestBed.get('a')).toBe('mockA: depValue'); }); - fixmeIvy('FW-855: TestBed.get(Compiler) should return TestBed-specific Compiler instance') - .it('should support SkipSelf', () => { - @NgModule({ - providers: [ - {provide: 'a', useValue: 'aValue'}, - {provide: 'dep', useValue: 'depValue'}, - ] - }) - class MyModule { - } + it('should support SkipSelf', () => { + @NgModule({ + providers: [ + {provide: 'a', useValue: 'aValue'}, + {provide: 'dep', useValue: 'depValue'}, + ] + }) + class MyModule { + } - TestBed.overrideProvider( - 'a', - {useFactory: (dep: any) => `mockA: ${dep}`, deps: [[new SkipSelf(), 'dep']]}); - TestBed.configureTestingModule( - {providers: [{provide: 'dep', useValue: 'parentDepValue'}]}); + TestBed.overrideProvider( + 'a', {useFactory: (dep: any) => `mockA: ${dep}`, deps: [[new SkipSelf(), 'dep']]}); + TestBed.configureTestingModule( + {providers: [{provide: 'dep', useValue: 'parentDepValue'}]}); - const compiler = TestBed.get(Compiler) as Compiler; - const modFactory = compiler.compileModuleSync(MyModule); - expect(modFactory.create(getTestBed()).injector.get('a')) - .toBe('mockA: parentDepValue'); - }); + const compiler = TestBed.get(Compiler) as Compiler; + const modFactory = compiler.compileModuleSync(MyModule); + expect(modFactory.create(getTestBed()).injector.get('a')).toBe('mockA: parentDepValue'); + }); it('should keep imported NgModules eager', () => { let someModule: SomeModule|undefined;