Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toHaveAccessibleDescription does not include aria-label text #500

Closed
greypants opened this issue Jun 14, 2023 · 3 comments
Closed

toHaveAccessibleDescription does not include aria-label text #500

greypants opened this issue Jun 14, 2023 · 3 comments

Comments

@greypants
Copy link

greypants commented Jun 14, 2023

  • @testing-library/jest-dom: "5.16.5"
  • @testing-library/react: "13.4.0"
  • node version: 18

Relevant code or config:

  it("includes svg aria-label in description text", () => {
    render(
      <>
        <label htmlFor="input-id">input</label>
        <input id="input-id" aria-describedby="description-id" />
        <div id="description-id">
          <svg role="img" aria-label="error" /> message
        </div>
      </>
    );

    expect(screen.getByLabelText("input")).toHaveAccessibleDescription("error message");
  });

What you did:

Screen readers include the svg aria-label in the accessible description, but jest-dom does not.

What happened:

    Expected element to have accessible description:
      error message
    Received:
      message

Reproduction:

https://codesandbox.io/s/react-testing-library-demo-forked-45xzdn?file=/src/__tests__/toHaveAccessibleDescription.js

Problem description:

aria-label contents are not included in the accessible description.

Suggested solution:

aria-label contents should be included in accessible descriptions.

@greypants greypants changed the title toHaveAccessibleDescription does not include aria-label text toHaveAccessibleDescription does not include aria-label text Jun 14, 2023
@greypants greypants changed the title toHaveAccessibleDescription does not include aria-label text toHaveAccessibleDescription: does not include aria-label text Jun 14, 2023
@greypants greypants changed the title toHaveAccessibleDescription: does not include aria-label text toHaveAccessibleDescription does not include aria-label text Jun 14, 2023
@gnapse
Copy link
Member

gnapse commented Jun 14, 2023

This library does not compute the accessible description itself. It relies on dom-accessibility-api for this.

@eps1lon as the owner of the repo for dom-accessibility-api, would you be able to chime in? I'm not sure if this is a known issue, or if we can transfer this issue to your repository.

I'm going to close this one, just because the fix does not lie in this library. But we can continue the discussion or even re-open if we need to.

@gnapse gnapse closed this as completed Jun 14, 2023
@eps1lon
Copy link
Member

eps1lon commented Jun 14, 2023

@greypants Can you file this against https://github.com/eps1lon/dom-accessibility-api please so that we can track (we can't move the issue there unfortunately)?

@greypants
Copy link
Author

Thanks! Moved here: eps1lon/dom-accessibility-api#955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants