testing-library / dom-testing-library

🐙 Simple and complete DOM testing utilities that encourage good testing practices.
https://testing-library.com/dom
MIT License
3.26k stars 467 forks source link

getByRole cannot query input type=text with happy-dom #1137

Closed frankandrobot closed 2 years ago

frankandrobot commented 2 years ago

Relevant code or config:

// UI
      <input
        defaultValue="hello"
        aria-label="name"
        id="name"
        style={{ maxWidth: "280px" }}
        type="text"
      />

// test
  expect(screen.getByRole("textbox", { name: /name/i }));

What you did:

What happened:

    TestingLibraryElementError: Unable to find an accessible element with the role "textbox" and name `/name/i`

    Here are the accessible roles:

      searchbox:

      Name "name":
      <input
        aria-label="name"
        defaultvalue="hello"
        id="name"
        style="max-width: 280px;"
        type="text"
      />

Reproduction:

Problem description:

Suggested solution:

timdeschryver commented 2 years ago

This has been working for a while now with JSDOM and in browsers. It's most likely that this is happy-dom's side.

1122 is related.