In keeping with Guiding Principle #2, I would like to assert what accessible name will be emitted for an element by screen readers and such. Currently this task, which all users of testing-library should be doing, requires implementing a very complicated algorithm or relying on a third-party dependency like the archived accname package.
Suggested implementation:
getAccessibleName(myElement)
Workaround:
expect(screen.getByRole('button', { name: expectedName })).toBe(myElement);
This gives the correct result, but in the failure case the debugging information is unsatisfactory ("expected x, received null" instead of showing the expected and actual name side-by-side).
In keeping with Guiding Principle #2, I would like to assert what accessible name will be emitted for an element by screen readers and such. Currently this task, which all users of
testing-libraryshould be doing, requires implementing a very complicated algorithm or relying on a third-party dependency like the archived accname package.Suggested implementation:
getAccessibleName(myElement)Workaround:
This gives the correct result, but in the failure case the debugging information is unsatisfactory ("expected x, received null" instead of showing the expected and actual name side-by-side).