testing-library-docs icon indicating copy to clipboard operation
testing-library-docs copied to clipboard

Framework wrappers and DOM testing library

Open jacklaurencegaray opened this issue 4 months ago • 3 comments

Describe the bug Docs seem confusing or conflicting itself

To Reproduce Steps to reproduce the behavior:

Go to this page: https://testing-library.com/docs/user-event/install/

It says:

If you use one of the framework 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.

But going to one of the framework wrappers: https://testing-library.com/docs/react-testing-library/intro

It says:

To get started with React Testing Library, you'll need to install it together with its peerDependency @testing-library/dom:

So, should we include @testing-library/dom or not?

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

jacklaurencegaray avatar Aug 14 '25 10:08 jacklaurencegaray

Hi @jacklaurencegaray, thanks for opening this one. Actually, in React Testing Library we've made this change since version 16 to not include DTL and I assume this comment in our docs is prior to that change. We're happy to accept PRs to the docs to fix this :)

MatanBobi avatar Aug 19 '25 11:08 MatanBobi

Just to clarify, this means that installing DTL moving forward is not necessary anymore right? And the change in docs I have to do is to remove the part that states you need to install it in the RTL docs?

jacklaurencegaray avatar Aug 19 '25 11:08 jacklaurencegaray

No that's actually the opposite :) In RTL we're not installing DTL as a dependency anymore and it has moved to be a peerDependency. That means that a user trying to install RTL will need to install DTL too so the docs in RTL are correct.

MatanBobi avatar Aug 19 '25 11:08 MatanBobi