Wednesday, February 12, 2020

Use querySelectorAll instead of querySelector to get something other than the very first match in a Jasmine/Karma test!

it(`should place '123' in first table detail`, () => {
   const compiled = fixture.debugElement.nativeElement;
   const mainTable = compiled.querySelectorAll('table')[1];
   expect(mainTable.querySelector('td').textContent).toContain('123');
});

No comments:

Post a Comment