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

Revert "Add peer dependency to User Event docs" #1329

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

nickmccurdy
Copy link
Member

@nickmccurdy nickmccurdy commented Oct 28, 2023

Reverts #888

user-event's recommendation for installing dom appears to be outdated, as package managers (except npm 3-6 and Yarn) automatically install dependencies anyway.

@netlify
Copy link

netlify bot commented Oct 28, 2023

Deploy Preview for testing-library ready!

Name Link
🔨 Latest commit dc93936
🔍 Latest deploy log https://app.netlify.com/sites/testing-library/deploys/654d85be1f9bb10008b69995
😎 Deploy Preview https://deploy-preview-1329--testing-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@MatanBobi
Copy link
Member

AFAIU from the code, @testing-library/dom is still a peer dependency, doesn't that mean we still need that? I understand that if a user installs @testing-library/react for example they'll have it installed but if a user only installs user-event, this might still be needed don't you think?

@nickmccurdy
Copy link
Member Author

nickmccurdy commented Oct 30, 2023

Not likely since npm 7 installs peer dependencies automatically (again).

Context: I just checked blame and this was apparently my fault. 😅 At the time npm 7 was new so I couldn't depend on peer dependencies being installed automatically. Now npm 7 has been included with Node for 3 years and support for older releases ended 6 months ago, so I'm not as concerned about compatibility. If a user has a package manager that doesn't install peer dependencies (including npm 3-6 and Yarn), it will still warn by default.

@nickmccurdy nickmccurdy marked this pull request as ready for review October 30, 2023 18:44
@nickmccurdy nickmccurdy changed the title docs: don't install @testing-library/dom Revert "Add peer dependency to User Event docs" Oct 31, 2023
Comment on lines 31 to 17
If you use one of the
[framework wrappers](../dom-testing-library/install.mdx#wrappers), it is
important that `@testing-library/dom` is resolved to the same installation
required by the framework wrapper of your choice.
Usually this means that if you use one of the framework wrappers, you should not
add `@testing-library/dom` to your project dependencies.
Copy link
Member

Choose a reason for hiding this comment

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

I think we should keep this note.
When people upgrade e.g. their version of @testing-library/react the @testing-library/dom package isn't always deduplicated. I'd rather add examples how to diagnose and fix this to further reduce retyped text when I suspect this to be the root of someeone's problem (e.g. "user-event only types the first N characters").

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you suggesting we revert this deletion and add examples of specific use cases? Could you please give some examples? Peer dependency management is in a much better state than it used to be, and I'm not sure it's worth the maintenance burden of us documenting anymore. I want to either document more use cases which I believe isn't worth the effort, or remove this as no documentation is usually better than outdated or inaccurate documentation.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I would keep this paragraph on duplicate versions of /dom.
I'm under the impression this ranks as the second most common reason for act warnings and wrong input with UserEvent after missing await. Both isn't our fault and should not happen, but it does and we still have to deal with people running into these problems.
Therefore I'd like to have a section I can point to if I suspect this problem. The exact combinations of packages and package managers change over time and maintaining a list of them is out of scope of our docs. But if we feel that this paragraph isn't perspicuous, maybe we should add some explanation/example.

@MatanBobi
Copy link
Member

Since people don't really care about the warnings from the npm i script, maybe we can add a note about that for old users?

@nickmccurdy
Copy link
Member Author

nickmccurdy commented Nov 2, 2023

A note about what? Can you give an example?

@MatanBobi
Copy link
Member

A note about what? Can you give an example?

That explicitly installing @testing-library/dom is still needed if you're using npm < 7. Since user-event doesn't have an engines definition and @testing-library/react for example still support node 14 which originally was bundled with npm 6.
That's just an idea, you can ignore it if you don't think it's needed :)

@nickmccurdy
Copy link
Member Author

nickmccurdy commented Nov 2, 2023

Our engines are out of date because Node 16 support was recently dropped, but I'll make sure this is fixed soon and users should have already upgraded Node for security reasons anyway.

I'd really prefer to keep the original revert of my change (the first commit in this pull ignoring formatting changes) as it's now outdated advice and it's not even consistent with User Event's readme. If you have any strong opinions against this please say so, preferably with explicit examples of potentially problematic use cases.

@MatanBobi
Copy link
Member

Our engines are out of date because Node 16 support was recently dropped, but I'll make sure this is fixed soon and users should have already upgraded Node for security reasons anyway.

I'd really prefer to keep the original revert of my change (the first commit in this pull ignoring formatting changes) as it's now outdated advice and it's not even consistent with User Event's readme. If you have any strong opinions against this please say so, preferably with explicit examples of potentially problematic use cases.

We'll probably update those once the major version for DTL will merged.
I understand, I'm good with that :)

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.

None yet

3 participants