user-event has unmet peer dependency dom

Created on 27 Aug 2020  ·  2Comments  ·  Source: testing-library/user-event

Using @testing-library/[email protected] and @testing-library/react"@10.4.9 in a project and when running yarn install I get the following warning:

warning " > @testing-library/[email protected]" has unmet peer dependency "@testing-library/dom@>=7.21.4".

I see that @testing-library/dom is listed in devDependencies so not sure why this is happening 🤷‍♂️ https://github.com/testing-library/user-event/blob/a5b335026abe9692a85190180603597da9687496/package.json#L44

Looks like this was raised and resolved previously https://github.com/testing-library/user-event/issues/335 and also mentioned in CRA https://github.com/facebook/create-react-app/issues/8446

Thoughts?

Most helpful comment

For what it's worth, I just tried using the user-event library for the first time and ran into the same issue, but it's a test/compilation failure for me (yarn2, jest).

Test suite failed to run

    @testing-library/user-event tried to access @testing-library/dom (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.

    Required package: @testing-library/dom (via "@testing-library/dom")
    Required by: @testing-library/user-event@virtual:c72221a37f247765bf95117c07460d0dd314f91d55e5ef517953f22f13abe08a4eb4ca8da63ad8106639299813447710808040a06701c40efe08bad531b61747#npm:12.1.3 (via /Users/sj/Developer/myrepo/.yarn/$$virtual/@testing-library-user-event-virtual-114389dc81/0/cache/@testing-library-user-event-npm-12.1.3-4ed5fba7b9-af9844d63d.zip/node_modules/@testing-library/user-event/dist/)
    Ancestor breaking the chain: sample@workspace:.

    Require stack:
      .yarn/$$virtual/@testing-library-user-event-virtual-114389dc81/0/cache/@testing-library-user-event-npm-12.1.3-4ed5fba7b9-af9844d63d.zip/node_modules/@testing-library/user-event/dist/click.js
      .yarn/$$virtual/@testing-library-user-event-virtual-114389dc81/0/cache/@testing-library-user-event-npm-12.1.3-4ed5fba7b9-af9844d63d.zip/node_modules/@testing-library/user-event/dist/index.js
      src/app/sign-in.test.tsx

package.json:

 "devDependencies": {
    ...
    "@testing-library/cypress": "^6.0.1",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.0.0",
    "@testing-library/user-event": "^12.1.3",

Installing @testing-library/dom fixes the error.

All 2 comments

Hi @samit4me 👋 thanks for bringing this up 🙂
You can find an explanation of why this is here https://github.com/testing-library/user-event/pull/438#issuecomment-680134095
Long story short, the problem will be fixed in the future but for now, having a warning is the least evil.
I'm closing this issue but feel free to comment further if you have any followup.

For what it's worth, I just tried using the user-event library for the first time and ran into the same issue, but it's a test/compilation failure for me (yarn2, jest).

Test suite failed to run

    @testing-library/user-event tried to access @testing-library/dom (a peer dependency) but it isn't provided by your application; this makes the require call ambiguous and unsound.

    Required package: @testing-library/dom (via "@testing-library/dom")
    Required by: @testing-library/user-event@virtual:c72221a37f247765bf95117c07460d0dd314f91d55e5ef517953f22f13abe08a4eb4ca8da63ad8106639299813447710808040a06701c40efe08bad531b61747#npm:12.1.3 (via /Users/sj/Developer/myrepo/.yarn/$$virtual/@testing-library-user-event-virtual-114389dc81/0/cache/@testing-library-user-event-npm-12.1.3-4ed5fba7b9-af9844d63d.zip/node_modules/@testing-library/user-event/dist/)
    Ancestor breaking the chain: sample@workspace:.

    Require stack:
      .yarn/$$virtual/@testing-library-user-event-virtual-114389dc81/0/cache/@testing-library-user-event-npm-12.1.3-4ed5fba7b9-af9844d63d.zip/node_modules/@testing-library/user-event/dist/click.js
      .yarn/$$virtual/@testing-library-user-event-virtual-114389dc81/0/cache/@testing-library-user-event-npm-12.1.3-4ed5fba7b9-af9844d63d.zip/node_modules/@testing-library/user-event/dist/index.js
      src/app/sign-in.test.tsx

package.json:

 "devDependencies": {
    ...
    "@testing-library/cypress": "^6.0.1",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.0.0",
    "@testing-library/user-event": "^12.1.3",

Installing @testing-library/dom fixes the error.

Was this page helpful?
0 / 5 - 0 ratings