refactor(schematics): remove unnecessary compileComponents#33082
refactor(schematics): remove unnecessary compileComponents#33082JeanMeche wants to merge 1 commit intoangular:mainfrom
compileComponents#33082Conversation
angular/angular/pull/61230 updated `TestBed`'s behavior of components with async metadata. `TestBed` will now only throw when `overrideComponent()` is used on a component with a `@defer` block
e7e1739 to
f0927f1
Compare
There was a problem hiding this comment.
Code Review
This pull request removes unnecessary compileComponents() calls and associated async/await syntax from Angular unit test templates and test files. These changes affect application and component schematics, as well as existing unit tests, streamlining the test setup. A test case verifying the presence of compileComponents() was also removed to align with these changes. I have no feedback to provide.
| await TestBed.configureTestingModule({ | ||
| imports: [App], | ||
| }).compileComponents(); | ||
| }); |
There was a problem hiding this comment.
I think the call to configureTestingModule should be kept, even if empty, as it sets globally defined options like errorOnUnknownProperties IIRC
There was a problem hiding this comment.
Afaik, there a fallbacks on options that aren't set. I personnaly rarely use it if I have no providers to override (in the context of standalone components).
There was a problem hiding this comment.
There is a fallback, but it is only read when configureTestingModule() applies the TestBed options to the runtime strict-mode flags. createComponent() does not go through that path (at least it wasn't when I implemented it a few years ago, and I don't think it changed).
So if errorOnUnknownProperties is configured to true globally, as the CLI does by default, and the test does not call configureTestingModule(), unknown-property validation still uses the runtime default (false). Adding configureTestingModule() later, for example to override a provider, would then also start applying the global option and change the test behavior. This is the same for a handful of options.
angular/angular/pull/61230 updated
TestBed's behavior of components with async metadata.TestBedwill now only throw whenoverrideComponent()is used on a component with a@deferblock