Recently, I started working with the shadow DOM and encountered a strange issue:
In my Ionic Angular application, there is a text styled like a link in this form (simplified):
<a href="${ifDefined(this.href)}">link</a>
When testing for its existence using the following code:
const link = screen.getByShadowRole('link');
It appears that if the href attribute is removed due to being set via a variable, the role of the element as a link also gets removed, causing the test to fail. It seems like the a
tag loses its Role: Link designation when it doesn't have an href attribute.
I tried to find more information about this behavior but couldn't determine if it's a bug, expected behavior, or why the role is removed from the tag.