dom-testing-library: Custom testIdAttribute ignored
@testing-library/domversion: 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.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 19 (10 by maintainers)
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/domwithIf it discovers more than one version, upgrade all dependants and when it’s not possible, try Yarn resolutions
That’s a lint warning from the AirBnB lint config - they should really document when to disable it, e.g., for test files and local development scripts.
I think we already do re-export everything from
@testing-library/domhere and actually there’s no real need to install@testing-library/domas far as I remember and as far as the docs say here.