Closed Tasiobg closed 1 month ago
Since this update https://github.com/testing-library/dom-testing-library/pull/1241 the alt attribute for the img role can't be empty. My understanding is that the alt attribute should be present but in some cases like decorative images it should be empty, some info here
alt
img
Is this an issue or an intended change?
Works
it(`testcase`, async () => { render( <div> <img src="url" alt="alt text" /> </div>, ); expect(screen.getByRole('img')).toBeInTheDocument(); });
Fail
it(`testcase`, async () => { render( <div> <img src="url" alt="" /> </div>, ); expect(screen.getByRole('img')).toBeInTheDocument(); });
Hi @Tasiobg :) An image with an empty alt attribute has a role of none or presentation (based on the ARIA spec):
none
presentation
So this works as expected. Thanks for the report.
Since this update https://github.com/testing-library/dom-testing-library/pull/1241 the
alt
attribute for theimg
role can't be empty. My understanding is that thealt
attribute should be present but in some cases like decorative images it should be empty, some info hereIs this an issue or an intended change?
Works
Fail