Skip to content
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

Add peer dependency to User Event docs #888

Merged
merged 1 commit into from
Jul 18, 2021
Merged

Conversation

nickserv
Copy link
Member

@nickserv nickserv commented Jul 17, 2021

User Event peer depends on DOM Testing Library, so it needs to be manually installed, as stated in the readme.

Copy link
Member

@MatanBobi MatanBobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good for now, but I'm trying to understand why only user-event defines a peerDep unlike all the other packages that have testing-library/dom as a dependency.

@nickserv
Copy link
Member Author

nickserv commented Jul 18, 2021

There's rationale here: testing-library/user-event#135

@MatanBobi @kentcdodds @ph-fritsche Do you have any thoughts on this? I think it's a bit surprising that User Event still uses peer dependencies, while framework libraries like React Testing Library use regular dependencies. Does User Event rely on deduping DOM Testing Library in ways that React Testing Library does not? If the only issue is allowing more flexible dependency resolution, we could just put the >= version range on @testing-library/dom in dependencies.

Anyway I will merge this for now, since it's currently still a peer dependency, and the docs should be up to date with the readme.

@nickserv nickserv merged commit 0db925f into main Jul 18, 2021
@nickserv nickserv deleted the nickmccurdy-patch-2 branch July 18, 2021 09:04
@ph-fritsche
Copy link
Member

ph-fritsche commented Jul 18, 2021

I think that another copy of @testing-library/dom might cause problems with the config.
When importing e.g. @testing-library/react it automatically replaces the actWrapper and eventWrapper.

If @testing-library/dom imports inside @testing-library/userEvent resolves to another copy, it would be one with default config.

For the same reason projects should not add @testing-library/dom to their dependencies when working with one of the framework packages.

@kentcdodds
Copy link
Member

The reason is pretty simple actually.

People using @testing-library/react don't need to think about using or installing @testing-library/dom because it's a wrapper, but the people using @testing-library/user-event need to have @testing-library/dom installed (either directly or transitively via @testing-library/react) because it's a companion utility, not a wrapper.

@nickserv
Copy link
Member Author

nickserv commented Oct 31, 2023

Reverting this in #1329 (explanation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants