Skip to content

can't find element by role code #1100

Closed
@chiptus

Description

@chiptus
  • @testing-library/dom version: 12.1.2
  • Testing Framework and version:
    jest 27.4.3
  • DOM Environment:
    jsdom 16.6.0

Relevant code or config:

component

export default ({ name }) => <code>{name}</code>;

test

import "@testing-library/jest-dom/extend-expect";
import React from "react";
import { render } from "@testing-library/react";
import Code from "../hello";

test("To render a code element", () => {
  const { getByRole } = render(<Code name="Jill" />);
  expect(getByRole("code")).toBeInTheDocument();
});

What you did:

I searched the code element by role code, I expected to find it by https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/structural_roles

What happened:

The element is not found

Reproduction:

https://codesandbox.io/s/fail-to-find-role-code-qpzrs?file=/src/__tests__/hello.js

Problem description:

Per testing-library docs, it seems like it should work, as when I check the role of the element in chrome dev tools, I see 'code' as expected.

Suggested solution:

not sure, I've seen that aria-query doesn't support this role.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions