Skip to content

feat(core): support applying directives via TestBed.createComponent#68780

Open
chintankavathia wants to merge 1 commit into
angular:mainfrom
chintankavathia:feat/core/test/test-bed/support-directives
Open

feat(core): support applying directives via TestBed.createComponent#68780
chintankavathia wants to merge 1 commit into
angular:mainfrom
chintankavathia:feat/core/test/test-bed/support-directives

Conversation

@chintankavathia
Copy link
Copy Markdown
Contributor

@chintankavathia chintankavathia commented May 18, 2026

Add a directives option to TestComponentOptions that allows applying host directives to a component created via TestBed.createComponent(). This enables testing scenarios where directives need to be dynamically applied to the test component, including directives with bindings.

Closes #68779

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@pullapprove pullapprove Bot requested a review from JeanMeche May 18, 2026 11:35
@angular-robot angular-robot Bot added detected: feature PR contains a feature commit area: core Issues related to the framework runtime labels May 18, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 18, 2026
Add a `directives` option to `TestComponentOptions` that allows applying
host directives to a component created via `TestBed.createComponent()`.
This enables testing scenarios where directives need to be dynamically
applied to the test component, including directives with bindings.

Closes angular#68779
@chintankavathia chintankavathia force-pushed the feat/core/test/test-bed/support-directives branch from 15fbffb to 0910f13 Compare May 18, 2026 11:51
`#${rootElId}`,
this.testModuleRef,
undefined,
options?.directives,
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 didn't set this up intentionally, because TestBed.createComponent is meant for testing the component as it would be used in an app, not using arbitrary directives on it.

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

Labels

area: core Issues related to the framework runtime detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(core/testing): support directives option in TestBed.createComponent

2 participants