Skip to content

getByRole('meter') doesn't find meter element #1171

Closed
@idanen

Description

@idanen
  • @testing-library/dom version: ^8.17.0
  • Testing Framework and version: jest ^28.1.0
  • DOM Environment: In codesandbox

Relevant code or config:

test('getting by implicit "meter" role', () => {
  const aValue = 21;
  render(<Meter value={aValue} />);
  expect(screen.getByRole("meter")).toHaveValue(aValue);
});

function Meter({
  value = 0,
  min = 0,
  max = 0,
  low = 3,
  high = 90,
  label = "meter"
}) {
  return (
    <meter
      aria-label={label}
      value={value}
      min={min}
      max={max}
      low={low}
      high={high}
    />
  );
}

What you did:

Tried to fetch by (implicit) meter role

What happened:

Failed to get element

Reproduction:

https://codesandbox.io/s/react-testing-library-getbyrole-meter-forked-ziqc09

Problem description:

Should be able to fetch a meter element by implicit role

Suggested solution:

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