Skip to content

toHaveValue fails to find value for scrollbar and separator roles #735

Description

@JoshuaKGoldberg
  • @testing-library/jest-dom version: 6.9.1
  • node version: 26
  • jest (or vitest) version: n/a
  • npm (or yarn) version: n/a

Relevant code or config:

const dom = new JSDOM(`
  <div role="meter"       aria-label="Disk"           aria-valuenow="120"></div>
  <div role="progressbar" aria-label="Upload"         aria-valuenow="120"></div>
  <div role="scrollbar"   aria-label="Scroll"         aria-valuenow="120" aria-controls="panel" tabindex="0"></div>
  <div role="separator"   aria-label="Resize panels"  aria-valuenow="120" tabindex="0"></div>
  <div role="slider"      aria-label="Volume"         aria-valuenow="120" tabindex="0"></div>
  <div role="spinbutton"  aria-label="Quantity"       aria-valuenow="120" tabindex="0"></div>
`);

for (const role of ['meter', 'progressbar', 'scrollbar', 'separator', 'slider', 'spinButton']) {
  const element = dom.window.document.querySelector(`[role="${role}"]`);
  expect(element).toHaveValue(120);
}

What you did:

That should all pass, as the aria-valuenow values are all 120.

What happened:

  • Pass: meter, progressbar, slider, spinbutton
  • Fail: scrollbar, separator

Reproduction:

https://github.com/JoshuaKGoldberg/repros/tree/testing-library-jest-dom-aria-valuenow-roles

Problem description:

Per the WAI-ARIA spec, scrollbar and separator should be supported.

Suggested solution:

#736 🤗

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