testing-library / testing-library/dom-testing-library
Cannot access disabled button
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 3.3k
- Forks
- 474
- PR merge metrics
- No merged PRs in 30d
Description
@testing-library/domversion: 9.0.0- Testing Framework and version: vitest 0.28.5
- DOM Environment: jsdom 21.1.0
Relevant code or config:
const upload = screen.getByRole('button', { name: /upload/i });
What you did:
Updated from version 8.4.0 to 9.0.0 and rerun test.
What happened:
Error: Test timed out in 5000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
at Timeout.<anonymous> (file:///.../frontend/node_modules/@vitest/runner/dist/index.js:44:16)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7)
TestingLibraryElementError: Unable to find an accessible element with the role "button" and name `/upload/i`
There are no accessible roles. But there might be some inaccessible roles. If you wish to access them, then set the `hidden` option to `true`. Learn more about this here: https://testing-library.com/docs/dom-testing-library/api-queries#byrole
I tried the hidden: true option, but there was no change.
Reproduction:
Problem description:
Suggested solution:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported upgrade from @testing-library/dom 8.4.0 to 9.0.0 with Vitest 0.28.5 and jsdom 21.1.0, using screen.getByRole for the upload button. Trace the role-query behavior and add a focused regression test; done means the disabled button can be accessed as intended without the test timing out.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100