Angular unit test input value
<p>I have been reading official Angular2 documentation for unit testing (<a href="https://angular.io/docs/ts/latest/guide/testing.html" rel="noreferrer">https://angular.io/docs/ts/latest/guide/testing.html</a>) but I am struggling with setting a component's input field value so that its reflected in the component property (bound via ngModel). The screen works fine in the browser, but in the unit test I cannot seem to be able to set the fields value.</p>

<p>I am using below code. "fixture" is properly initialized as other tests are working fine. "comp" is instance of my component, and the input field is bound to "user.username" via ngModel.</p>

<pre><code>it('should update model...', async(() =&gt; {
    let field: HTMLInputElement = fixture.debugElement.query(By.css('#user')).nativeElement;
    field.value = 'someValue'
    field.dispatchEvent(new Event('input'));
    fixture.detectChanges();

    expect(field.textContent).toBe('someValue');
    expect(comp.user.username).toBe('someValue');
  }));
</code></pre>

<p>My version of Angular2:  <code>"@angular/core": "2.0.0"</code></p>