arunselvakumar / AngularNotes

0 stars 0 forks source link

Routers Testing #4

Open arunselvakumar opened 5 years ago

arunselvakumar commented 5 years ago

it(‘should have a router outlet’, () => { fixture.debugElement.query(By.directive(RouterDirective); expect(de).not.tobeNull(); });

Import { RouterTestingModule } from ‘@angular/router/testing’; // This is a routing module specifically designed for testing - it’s simplified and recouped from the browser.

Imports: Rout………

it(‘should have a link to todos page’, () => { fixture.debugElement.query(By.directive(RouterLinkWithHref)); // Not necessary the first element in the list. So use queryAll

Let debugElements = fixture.debugElement.queryAll();

—> Let index = debugElements.findIndex (de => de.properties[‘href’] === ‘/todos’); expect(index).toBeGreaterThan(-1); });

VERY VERY VERY IMPORTANT In Test Bed Configuration, TestBed.configureTestingModuel({ Schemas: [NO_ERRORS_SCHEMA] });