question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

For RC5, need to note breaking changes for testing ngModel

See original GitHub issue

This is a note for whoever’s preparing the Changelog for RC5 😃

With the split into new forms, ngModel is now always asynchronous when updating. This means that in tests, instead of calling ComponentFixture.detectChanges, you’ll need to use ComponentFixture.whenStable, which is asynchronous.

Before:

    let fixture = builder.createSync(InputComp);
    fixture.detectChanges();

    let inputBox = <HTMLInputElement> fixture.debugElement.query(By.css('input')).nativeElement;
    expect(inputBox.value).toEqual('Original Name');

After:

    let fixture = builder.createSync(InputComp);
    fixture.whenStable().then(() => {

      let inputBox = <HTMLInputElement> fixture.debugElement.query(By.css('input')).nativeElement;
      expect(inputBox.value).toEqual('Original Name');
   });

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

17reactions
choellercommented, Jul 20, 2016

@juliemr Is this supposed to be the final solution? To be honest this whenStable, autoDetectChanges and detectChanges hell is super frustrating. At the moment I find myself randomly adding all that stuff + some tick calls until at some point the test passes. 😕

2reactions
juliemrcommented, Jul 20, 2016

@choeller we’re discussing and brainstorming 😃 I get the frustration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

forms deprecated error with RC5 - angular
NOTE : docs seem to be missing or not completed yet. In RC5, new NgModule has been introduced. ... breaking changes in RC5....
Read more >
Developer Guide: Migrating from Previous Versions
Minor version releases in AngularJS introduce several breaking changes that may require changes to your application's source code; for instance from 1.0 to ......
Read more >
Unit testing ngModel in Angular 4
As mentioned above, this is because Angular does not automatically do change detection. Angular provides a testing utility on the fixture ...
Read more >
Getting Started with Angular 2 Step by Step: 5 - Forms and ...
UPDATE (18th May 2017): This tutorial has been updated to the latest version of Angular (Angular 4). Note that the Angular team has...
Read more >
Getting Started + Testing with Angular CLI and Angular 2 ...
I started creating Angular 2 applications when it was in beta ( back in March ). To keep up with Angular 2's changes,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found