-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@testing-library/dom should be a peer dependency #1103
Comments
The thing is that you can avoid package duplication with Typically, if you're in a React test you always import from |
Afaik I don't have a reproduction repo right now since I am working on a private company repo, but I can try to create one. See for example:
Is it another step though? This is also required for Something similar could be added for the install docs of
From my experience, this will not be enough to solve the Then |
I agree with @magnattic,
If you have all these installed in the same project, you can easily run into problems like |
I can confirm the issue of multiple In our case, it happened when updating to React 18 in a project with |
This issue doesn't affect npm users since npm doesn't have strict peer dependencies.
npm packages with peer dependencies typically suggest installing the package alongside its peer dependencies in a single command. This command is often presented in a view with a button to copy it in the interest of convenience (as yours already is). |
Resolving this one since as of version 16, |
Problem description:
@testing-library/dom
in the same project leads to bugs that are hard to catch, like confusing act warnings@testing-library/dom
is installed@testing-library/dom
is a dependency to@testing-library/react
@testing-library/user-event
has a peer dependency to@testing-library/dom
So if I use both
@testing-library/react
and@testing-library/user-event
(a common use case), my dependency tree needs to look like this right now:And now it's easy for the two versions of
@testing-library/dom
to diverge, leading to bugs. I have to use solutions like yarn'sresolutions
field to keep them in sync.Suggested solution:
Make all packages use the same instance of
@testing-library/dom
by making it a peer dependency of@testing-library/react
.I understand that this has the downside that the user has to install
@testing-library/dom
alongside the react package, even if he doesn't need it. But as long as multiple testing-library packages need the same version of@testing-library/dom
, this seems to be the cleanest solution to ensure that everything works correctly.If it was a peer dependency, the above dependency tree would look like this:
Only one instance, problem solved!
The text was updated successfully, but these errors were encountered: