You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding data-testid to <Link> won't add anything to the resulting HTML document, adding it to <a> or the element under <Link> will, so the exact proptypes check is correct here, and this is not a bug.
Its more of a unintentional restriction of testability, a feature request I guess.
If you have a Link that you want to test with Selenium/Cypress, you cannot add a data-testid prop to make it easy to find without causing this ugly error.
The use of this prop-types-exact lib makes it impossible.
Ah wait, I see what you mean. I was using a babel-plugin to generate the data tags. Placing one on the Link tag would never make it to the dom anyway as you said.
So the workaround I mentioned above is really the only viable solution, and is user-land.
lockbot
locked as resolved and limited conversation to collaborators
Jul 16, 2019
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
Describe the bug
When using the common
data-testid
practice for components (https://blog.kentcdodds.com/making-your-ui-tests-resilient-to-change-d37a6ee37269),prop-types-exact
prints errors that are not able to be disabled.Was added here: #2516
suprraz/babel-plugin-react-element-info#2
Solutions
a. Remove
prop-types-exact
b. Add another prop to
Link
that allows disabling it (escape hatch).Workaround
Wrap
Link
component, and don't adddata-testid
tonext/link
, only to the wrapper.The text was updated successfully, but these errors were encountered: