jeudi 28 juin 2018

Angular - set private Input() in test

Here is my component

class Component {
  @Input() private somePrivateInput: string;

}

Next, I want to test it. According to docs, I have:

 it('Should do something basing on input', (done: DoneFn) => {
    component.somePrivateInput ='something';

    fixture.detectChanges();

    expect(component.something()).toBeTruthy;
});

However I got ERROR in my-component(43,19): error TS2341: Property 'somePrivateInput' is private and only accessible within class 'SomeComponent'.

Aucun commentaire:

Enregistrer un commentaire