Skip to content

Change input after initial render #56

Closed
@Wykks

Description

@Wykks

Hi!

What's the correct way to change input after initial render ?
Because componentProperties only set input on the first render, but we cannot test subsequent input changes this way (which leads to subsequent calls to ngOnChanges).

For now, this works :

component.fixture.componentInstance.myInput = 'stuff';
component.detectChanges();

But accessing fixture is not recommended (https://testing-library.com/docs/angular-testing-library/api#fixture, and I agree with this), and since I do not consider testing dynamic input change is testing an implementation detail, I believe there's should be another way, right ?

Edit: Maybe something like this :

// component is a RenderResult here
component.setComponentInputs({
   myInput: 'value'
});
// And call detectChanges / ngOnChanges automatically

Also, thanks for this library it's really usefull !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions