Skip to content

Instantly share code, notes, and snippets.

@ManuelDeLeon
Last active April 13, 2020 02:59
Show Gist options
  • Save ManuelDeLeon/029d1e4649e839a376032226c47c9edd to your computer and use it in GitHub Desktop.
Save ManuelDeLeon/029d1e4649e839a376032226c47c9edd to your computer and use it in GitHub Desktop.
it("Displays each message in messages", () => {
const messagesService = TestBed.get(MessageService);
messagesService.messages = ["Alan", "Brito"];
fixture.detectChanges();
const divs: Array<HTMLDivElement> = fixture.debugElement
// The first div is the wrapper for the test component (e.g. <div _ngcontent-a-c1>)
.queryAll(By.css("div div div"))
.map((e) => e.nativeElement);
expect(divs.length).toBe(2);
expect(divs[0].textContent).toContain("Alan");
expect(divs[1].textContent).toContain("Brito");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment