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.
So when I checked there was no entry for @testing-library/dom . After installing it, it started working.