
This is a new feature of the Ivy TestBed. A common user pattern is to test one component with another. This is commonly done by creating a `TestFixture` component which exercises the main component under test. This pattern is more difficult if the component under test is declared in an NgModule but not exported. In this case, overriding the module is necessary. In g3 (and View Engine), it's possible to use an NgSummary to override the recompilation of a component, and depend on its AOT compiled factory. The way this is implemented, however, specifying a summary for a module effectively overrides much of the TestBed's other behavior. For example, the following is legal: ```typescript TestBed.configureTestingModule({ declarations: [FooCmp, TestFixture], imports: [FooModule], aotSummaries: [FooModuleNgSummary], }); ``` Here, `FooCmp` is declared in both the testing module and in the imported `FooModule`. However, because the summary is provided, `FooCmp` is not compiled within the context of the testing module, but _is_ made available for `TestFixture` to use, even if it wasn't originally exported from `FooModule`. This pattern breaks in Ivy - because summaries are a no-op, this amounts to a true double declaration of `FooCmp` which raises an error. Fixing this in user code is possible, but is difficult to do in an automated or backwards compatible way. An alternative solution is implemented in this PR. This PR attempts to capture the user intent of the following previously unsupported configuration: ```typescript TestBed.configureTestingModule({ declarations: [FooCmp, TestFixture], imports: [FooModule], }); ``` Note that this is the same as the configuration above in Ivy, as the `aotSummaries` value provided has no effect. The user intent here is interpreted as follows: 1) `FooCmp` is a pre-existing component that's being used in the test (via import of `FooModule`). It may or may not be exported by this module. 2) `FooCmp` should be part of the testing module's scope. That is, it should be visible to `TestFixture`. This is because it's listed in `declarations`. This feature effectively makes the `TestBed` testing module special. It's able to declare components without compiling them, if they're already compiled (or configured to be compiled) in the imports. And crucially, the behavior matches the first example with the summary, making Ivy backwards compatible with View Engine for tests that use summaries. PR Close #30578
build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles (#28871)
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
86.3%
JavaScript
8.5%
HTML
1.8%
Starlark
1.7%
CSS
1%
Other
0.6%