Why my RTL can't find my svg with a img role?

Viewed 545

For some reason, my test cannot find the svg element I assigned with an img role. The message i'm getting is the following one:

TestingLibraryElementError: Unable to find an accessible element with the role "img"
Here are the accessible roles:

  button:

  Name "Dropdown Component":
  <button
    class="sc-iwajpm kxxFEp sc-giAqHp fTUIOj"
    data-ref="dropdown-toggle"
    data-testid="default"
  />

But the svg does have a role attribute in the result code. I have no idea why de RTL can't find it. I don't know if there is any limitation that i'm missing.

<body>
  <div>
    <div
      class="src__Box-sc-1sbtrzs-0 sc-hBMUJo sc-fnVZcZ sc-iJCRrE fvCTKQ bHFTTX hwlzxX"
    >
      <button
        class="sc-iwajpm kxxFEp sc-giAqHp fTUIOj"
        data-ref="dropdown-toggle"
        data-testid="default"
      >
        Dropdown Component
        <div
          class="src__Box-sc-1sbtrzs-0 sc-bCwfaz fvCTKQ"
        >
          <svg
            aria-hidden="true"
            class="sc-bdnxRM fpcKXE"
            color="text"
            focusable="false"
            **role="img"
            size="16"
            viewBox="0 0 24 24"
          >
            <path
              d="M12 14.1675L6.4175 8.5575L5 9.9675L12 17L19 10L17.585 8.58625L12 14.1675Z"
            />
          </svg>
        </div>
      </button>
    </div>
  </div>
</body>

0 Answers
Related