Custom testIdAttribute ignored
See original GitHub issue@testing-library/dom
version: 7.29.4- Testing Framework and version: Jest
- DOM Environment:
Relevant code or config:
configure({ testIdAttribute: 'foobar' })
What you did:
Happily seeing getByTestId work, then I bumped to this version of dom-testing-library, and it stopped working.
What happened:
It’s clearly ignoring the config and searching for the default data-testid
:
TestingLibraryElementError: Unable to find an element by: [data-testid="bar"...
Reproduction:
Use configure({ testIdAttribute })
in any environment and see that it’s broken now.
Problem description:
Hundreds and hundreds of tests break.
Suggested solution:
It’s unfortunately hard to figure out where this broke because we get our dom-testing-library via @testing-library/react, which carets it, meaning it jumps from 7.27.1 -> 7.29.4. Somewhere in the commits in dom-testing-library between those two version numbers is the regression.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:19 (10 by maintainers)
Top Results From Across the Web
Configuration Options | Testing Library
import serialize from 'my-custom-dom-serializer' configure({ testIdAttribute: 'data-my-test-id', getElementError: (message, container) => {
Read more >Developers - Custom testIdAttribute ignored - - Bountysource
It's clearly ignoring the config and searching for the default data-testid : TestingLibraryElementError: Unable to find an element by: [data- ...
Read more >Unable to find the element with data-testid - Stack Overflow
I am following the docs for react-testing-library to find if the element with data-testid attribute is rendered or not. The react-testing- ...
Read more >What is the data-testid attribute in testing? - Educative.io
data-testid is an attribute used to identify a DOM node for testing purposes. It should be used as a handler to the test...
Read more >Some components ignore html data attributes
However, setting a data-testid attribute (or really any data- attribute) on a Kendo component does not always result in the attribute ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You mean “explicitly”? If not then I don’t think that “implicit documentation” works.
It would still be nice to confirm if this is indeed the problem.
Happened to me today again. For further readers, if you are using Yarn, simply check that you have only one version of
@testing-library/dom
withIf it discovers more than one version, upgrade all dependants and when it’s not possible, try Yarn resolutions