-
Notifications
You must be signed in to change notification settings - Fork 93
Add support for Angular bindings API with twoWayBinding #547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Angular bindings API with twoWayBinding #547
Conversation
Co-authored-by: timdeschryver <28659384+timdeschryver@users.noreply.github.com>
Co-authored-by: timdeschryver <28659384+timdeschryver@users.noreply.github.com>
@copilot please look at my review comments |
…arnings, remove v20 references Co-authored-by: timdeschryver <28659384+timdeschryver@users.noreply.github.com>
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@lacolaco is this what you had in mind? |
@timdeschryver Thanks. I'm gonna review in this week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, this is definitely what I wanted! I left some comments and suggestions on the implementation.
@copilot also add the functionality for Example: const checkboxValue = signal('');
createComponent(MyCheckbox, {
bindings: [
twoWayBinding('value', checkboxValue),
],
}); And resolve this comment:
|
Co-authored-by: timdeschryver <28659384+timdeschryver@users.noreply.github.com>
Added Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
46c5b80
to
04e96a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lacolaco !
Overview
This PR implements support for Angular's native bindings API in Angular Testing Library, addressing the suggestion in #526 that ATL's current input/output interfaces may be unnecessary with Angular's new approach.
What's New
Angular introduced a native bindings API that allows direct binding of inputs and outputs when creating components with
TestBed.createComponent()
:This PR adds seamless support for this pattern in ATL while maintaining full backward compatibility.
Usage Examples
New Bindings API
Traditional API (Still Supported)
Mixed Usage
Benefits
Implementation Details
bindings?: Binding[]
option toRenderComponentOptions
createComponent()
to useTestBed.createComponent(component, { bindings })
when bindings are provided@angular/core
Binding Types Supported
inputBinding()
- Bind input values, including with writable signals for dynamic updatesoutputBinding()
- Listen to component outputstwoWayBinding()
- Bidirectional data binding with writable signalsMixed Usage Behavior
Due to Angular's limitations, inputs and outputs behave differently when mixing approaches:
setInput()
withinputBinding()
, so bindings take complete precedence (with warning)outputBinding()
and traditionalon
listeners work togetherMigration Path
Users can gradually adopt the new bindings API:
inputs
/on
APIs - no changes requiredbindings
for new tests while keeping existing tests unchangedThis provides a smooth transition path while giving users access to Angular's modern testing capabilities.
Fixes #546
Fixes #546
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.