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';
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With