-
-
Notifications
You must be signed in to change notification settings - Fork 188
Closed
Labels
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:
Current behavior
When setting properties via createComponentFactory(TestComponent)({ props: {} }), ngOnChanges is not called.
Expected behavior
In the Angular LifeCycle, ngOnChanges is called when properties are set initially and it's called before ngOnInit(). This is a known problem unit testing components that aren't inside a host component, because directly setting properties on a component bypasses change detection.
What is the motivation / use case for changing the behavior?
I think that inside setProps() a SimpleChanges object can be built and the ngOnChanges function can be fired. This would help avoid confusion and google searches on why ngOnChanges isn't firing initially when directly testing a component.
aciccarello, krzyhan and ntvsx193cleever