This library calls detect changes on every property change
See original GitHub issue@Component({
template: `
count: {{ count }}
<button (click)="increment()">Increment</button>
`
})
export class Counter {
elementRef = inject(ElementRef)
count = 0
increment() {
this.count++
this.count++
this.count++
expect(elementRef.nativeElement).toHaveTextContent("count: 0")
}
}
await render(Counter)
fireEvent.click(screen.getByText("Increment"))
Expected result: count: 0
Actual result: count: 3
This is not correct Angular behavior and breaks custom change detection strategies.
Proposal: Use ComponentRef#setInput to change component properties instead.
Issue Analytics
- State:
- Created 10 months ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
Angular Change Detection - How Does It Really Work?
Angular can detect when component data changes, and then automatically re-render the view to reflect that change. But how can it do so...
Read more >ChangeDetectorRef - Angular
ChangeDetectorReflink. Base class that provides change detection functionality. A change-detection tree collects all views that are to be checked for changes.
Read more >Simplified Angular Change Detection | by Pankaj Parkar | ngconf
It runs a change detection for a component only when Input bindings value of a component is changed. Actually, it compares the reference...
Read more >The Last Guide For Angular Change Detection You'll Ever Need
This detector compares the current value with the previous value of the property. If the value has changed it will set isChanged to...
Read more >Listener for property value changes in a Javascript object
It also has a simple type check, which calls the onerror event if it fails. ... Whenever the p property is changed, any...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This is released in v13 🥳 Thanks @antischematic !
@timdeschryver Thanks for that, my tests are now passing 13.0.0-beta-9 without any issues.