import '@testing-library/jest-dom/extend-expect';
expect(screen.getByText('User does not exist.')).toBeInTheDocument()
I'm writing the unit test for my web app, I use toBeInTheDocument() in my code, but after i run npm test in terminal, it shows that 'Cannot find module '@testing-library/jest-dom/extend-expect' from 'jest.setup.js''.
I have a jest.setup.js file which includes the code:require('@testing-library/jest-dom/extend-expect');
and also a jest.config.js file which includes the code: setupFilesAfterEnv:["./jest.setup.js"],
and I also import '@testing-library/jest-dom/extend-expect'; in my test.tsx file, also check the node_modules there is @testing-library/jest-dom under it. what should I do now?`
import '@testing-library/jest-dom'
– Inch