dimanche 3 septembre 2017

How to write tests when Angular dynamically set CSS-classes?

I have this html:

<a routerLink="/about" routerLinkActive="active">some text</a>

And I have this test:

it(`should find a.active element`, async(() =>
{
  fixture.detectChanges();
  debug = fixture.debugElement.query(By.css('a.active'));
  expect(debug).toBeTruthy();
}));

Why debug here is null? Why Angular can't find a.active element even after fixture.detectChanges();?

Aucun commentaire:

Enregistrer un commentaire