Skip to content

Comments

docs: use standalone component pattern in harness guide examples#32828

Open
yogeshwaran-c wants to merge 1 commit intoangular:mainfrom
yogeshwaran-c:docs/harness-guide-standalone
Open

docs: use standalone component pattern in harness guide examples#32828
yogeshwaran-c wants to merge 1 commit intoangular:mainfrom
yogeshwaran-c:docs/harness-guide-standalone

Conversation

@yogeshwaran-c
Copy link

What kind of change does this PR introduce?

Documentation

What is the current behavior?

The "Using component harnesses" guide uses the legacy declarations + NgModule imports pattern in its TestBed setup examples:

TestBed.configureTestingModule({
  imports: [IssueReportSelectorModule],
  declarations: [IssueReportSelector],
});

This is the NgModule-based testing pattern which is outdated now that Angular defaults to standalone components.

Partially addresses #32709

What is the new behavior?

All three TestBed configuration examples are updated to use the standalone component pattern:

await TestBed.configureTestingModule({
  imports: [IssueReportSelector],
}).compileComponents();

Changes:

  • Removed declarations arrays (standalone components are imported, not declared)
  • Removed NgModule imports (e.g., IssueReportSelectorModule, MyModule)
  • Added await and .compileComponents() to follow current best practices
  • Fixed a minor syntax issue (missing closing parenthesis on describe block)

Additional context

The two comparison examples ("without harnesses" and "with harnesses") were both updated to maintain their parallel structure. This is a follow-up to the standalone migration work in PRs #32815, #32825, #32826, and #32827.

The component harness testing guide used the legacy
declarations + NgModule imports pattern in all three TestBed
configuration examples. Update to use standalone component imports
which is the default pattern in modern Angular.

Partially addresses angular#32709
@angular-robot angular-robot bot added the area: docs Related to the documentation label Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Related to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant