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

Aria labels not coming through aria descriptions #1064

Open
HeartSquared opened this issue Oct 9, 2024 · 0 comments
Open

Aria labels not coming through aria descriptions #1064

HeartSquared opened this issue Oct 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@HeartSquared
Copy link

Initially reported in testing-library/dom-testing-library#1336.
Opening issue here as requested.


Relevant code:

  it("RTL example", () => {
    const Input = (): JSX.Element => (
      <>
        <label htmlFor="id--input">Label</label>
        <input
          type="text"
          id="id--input"
          aria-describedby="id--error-msg"
        />
        <div id="id--error-msg">
          <span aria-label="icon_label">icon_name</span>
          <span>The error message</span>
        </div>
      </>
    )
    const { getByRole } = render(<Input />)
    const input = getByRole("textbox", {
      description: "icon_label The error message",
    })

    expect(input).toBeInTheDocument()
  })

What you did:

Found discrepancy between browser results and unit test using the exact same snippet.
The snippet is a simpler version of our TextField component, where the validation message is prefixed with a font icon with an aria-label.

What happened:

Browser Testing Library
Screenshot 2024-10-03 at 11 08 26 AM Screenshot 2024-10-03 at 11 09 07 AM

Problem description:

Not reflective of the real result.

@eps1lon eps1lon added the bug Something isn't working label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants