title: Angular2 unit testing does not update input's ngModel when used inside a form
body: <p>I have fairly extensive testing in our Angular 2.4 based application.  One area we have not been able to test though is forms with inputs.  I finally tracked this down to a small test case.  I have a plnkr that shows the issue: <a href="https://plnkr.co/edit/NyeAoh2Uo5rJT9if6j64" rel="nofollow noreferrer">https://plnkr.co/edit/NyeAoh2Uo5rJT9if6j64</a>  (see form_bug.spec.ts)</p>
  
  <p>Note: I based this example off the way the code in the testing guide works.</p>
  
  <p>The problem is that when we hook an input up with ngModel, and then in the test suite we update the input the data will flow into the component only if the input is not inside a form.  If we add it to a form, then the data will not flow correctly.</p>
  
  <p>The core pieces of the code are:</p>
  
  <pre><code>@Component({
     selector: 'with-form-test',
     template: `
     &lt;div&gt;
        &lt;div class="show_val"&gt;{{testVal}}&lt;/div&gt;
        &lt;form&gt;
           &lt;input name="test_val" id="val_id" [(ngModel)]="testVal" /&gt;
        &lt;/form&gt;
     &lt;/div&gt;
     `,
  })
  class WithFormTestComp {
     testVal: string = 'start';
  }
  </code></pre>
  
  <p>and the test.  The two expect() checks in this one fail.</p>
  
  <pre><code>describe('WithFormTest', () =&gt; {
     let fixture: ComponentFixture&lt;WithFormTestComp&gt;;
     let comp:    WithFormTestComp;
     let comp_de: DebugElement;
  
     function getInput(): DebugElement {
        return comp_de.query(By.css('input'));
     }
     function getShowVal(): DebugElement {
        return comp_de.query(By.css('.show_val'));
     }
  
     beforeEach(() =&gt; {
        TestBed.configureTestingModule({
           imports: [
              FormsModule,
           ],
           declarations: [
              WithFormTestComp,
           ],
        });
  
        fixture = TestBed.createComponent(WithFormTestComp);
        comp    = fixture.componentInstance;
        comp_de = fixture.debugElement;
     });
  
     it('should update testVal', () =&gt; {
        fixture.detectChanges();
        const input_elt: HTMLInputElement = getInput().nativeElement;
  
        input_elt.value = 'set_val';
        input_elt.dispatchEvent(newEvent('input'));
        fixture.detectChanges();
  
        const show_val_elt = getShowVal().nativeElement;
  
        expect(comp.testVal).toEqual('set_val');
        expect(show_val_elt.textContent).toBe('set_val');
     });
  
  });
  </code></pre>
  
  <p>Does anyone see how to fix this up so that it will work correctly?  I have looked around and can't find any bug reports that explain why this would work without the form but fail with it.</p>