Skip to content

refactor(schematics): remove unnecessary compileComponents - #33082

Open
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:compile-components
Open

refactor(schematics): remove unnecessary compileComponents#33082
JeanMeche wants to merge 1 commit into
angular:mainfrom
JeanMeche:compile-components

Conversation

@JeanMeche

Copy link
Copy Markdown
Member

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

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
@JeanMeche
JeanMeche force-pushed the compile-components branch from e7e1739 to f0927f1 Compare April 28, 2026 19:48
@JeanMeche
JeanMeche marked this pull request as ready for review April 28, 2026 20:04

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@JeanMeche
JeanMeche requested a review from clydin April 28, 2026 20:32
await TestBed.configureTestingModule({
imports: [App],
}).compileComponents();
});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the call to configureTestingModule should be kept, even if empty, as it sets globally defined options like errorOnUnknownProperties IIRC

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants