Skip to content

Commit 066ec33

Browse files
gkalpakkara
authored andcommitted
fix(ivy): allow R3TestBedCompiler to work in ngcc-processed apps (angular#28530)
Previously, `R3TestBedCompiler` was dynamically defining an `@NgModule`-decorated `CompilerModule` class inside a method call. Since ngcc only processes top-level classes, this class was not transformed causing failures in unit tests (see angular#30121 for details). This commit fixes it by using `compileNgModuleDefs()` directly (similar to the fix in angular#30037). Fixes angular#30121 PR Close angular#28530
1 parent 5b80ab3 commit 066ec33

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

packages/core/testing/src/r3_test_bed_compiler.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,8 @@ export class R3TestBedCompiler {
548548
}
549549

550550
// TODO(ocombe): make this work with an Injector directly instead of creating a module for it
551-
@NgModule({providers})
552-
class CompilerModule {
553-
}
551+
class CompilerModule {}
552+
compileNgModuleDefs(CompilerModule as NgModuleType<any>, {providers});
554553

555554
const CompilerModuleFactory = new R3NgModuleFactory(CompilerModule);
556555
this._injector = CompilerModuleFactory.create(this.platform.injector).injector;

0 commit comments

Comments
 (0)