0

I have a text container with a few links. I want to test link presence with particular href, no matter what text within.

How can I do it?

<div class="styles_info__5-SjJ">
Lorem ipsum <a href="https://my.link">dolor</a> sit <a href="https://another.link">amet</a>
</div>

I've tried

expect(screen.getByRole("link")).toHaveAttribute("href","https://my.link");

Got error:

TestingLibraryElementError: Found multiple elements with the role "link"

Tried

expect(screen.getAllByRole("link")).toHaveAttribute("href","https://my.link");

Got error:

received value must be an HTMLElement or an SVGElement.
Received has type: array

Artem Reva
  • 13
  • 4

0 Answers0