Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module '@testing-library/dom' from 'node_modules/@testing-library/user-event/dist/click.js' Require stack:

In a project we recently started using userEvent instead of fireEvent but now we are getting this issue

FAIL src/modules/DashboardHeader/index.test.tsx     

      ● Test suite failed to run  

        Cannot find module '@testing-library/dom' from 'node_modules/@testing-library/user-event/dist/click.js'  

        Require stack:  

          node_modules/@testing-library/user-event/dist/click.js  

          node_modules/@testing-library/user-event/dist/index.js  

          src/modules/DashboardHeader/index.test.tsx  

           5 | 
           6 | 
        >  7 | import userEvent from '@testing-library/user-event';  
like image 751
paraS elixiR Avatar asked Feb 23 '26 04:02

paraS elixiR


1 Answers

As per the documentation https://testing-library.com/docs/ecosystem-user-event/

in order to use userEvent, we need not just "@testing-library/user-event" but also @testing-library/dom.

npm install --save-dev @testing-library/user-event @testing-library/dom 

So when I checked there was no entry for @testing-library/dom . After installing it, it started working.

like image 54
paraS elixiR Avatar answered Feb 24 '26 17:02

paraS elixiR



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!