Alex Rickabaugh
df292c2ce0
fix(ivy): TestBed should not clobber compilation of global-scope modules (#28033)
When an @NgModule decorator executes, the module is added to a queue in render3/jit/module.ts. Reading an ngComponentDef property causes this queue to be flushed, ensuring that the component gets the correct module scope applied. In before_each.ts, a global beforeEach is added to all Angular tests which calls TestBed.resetTestingModule() prior to running each test. This in turn clears the module compilation queue (which is correct behavior, as modules declared within the test should not leak outside of it via the queue). So far this is okay. But before the first test runs, the module compilation queue is full of modules declared in global scope. No definitions have been read, so no flushes of the queue have been triggered. The global beforeEach triggers a reset of the queue, aborting all of the in-progress global compilation, breaking those classes when they're later used in tests. This commit adds logic to TestBedRender3 to respect the state of the module queue before the TestBed is first initialized or reset. The queue is flushed prior to such an operation to ensure global compilation is allowed to finish properly. With this fix, a platform-server test now passes (previously the <my-child> element was not detected as a component, because the encompassing module never finished compilation. FW-887 #resolve PR Close #28033
Angular
Angular is a development platform for building mobile and desktop web applications using Typescript/JavaScript and other languages.
Quickstart
Changelog
Learn about the latest improvements.
Want to help?
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.
Description
Languages
TypeScript
68.6%
HTML
12.8%
JavaScript
8.4%
Pug
7%
Starlark
1.4%
Other
1.7%