Version 6.0.1 returns cannot find module
tonskton opened this issue · comments
@testing-library/jest-dom
version: ^6.0.1node
version: v18.16.1npm
(oryarn
) version: yarn 1.22.19
Relevant code or config:
// jest.config.js
import '@testing-library/jest-dom/extend-expect';
What you did:
Trying to run a test in next js
What happened: It returns an cannot find module error even though the library is in the package.json under dev dependencies
"Cannot find module '@testing-library/jest-dom/extend-expect' from 'jest.setup.js'"
Reproduction:
Problem description:
Tried to run npm test with next js but returns a cannot find module with jest-dom using the latest version(6.0.1).
If you try to hover then click the imported library vs code will typically route you the the file, but in this case it seems like vs code cant find the js-dome library.
@testing-library/jest-dom
is already existing in package json dev dependency.- Already tried deleting node_modules and lock file but error still there.
I tried switching to older version like 5.6 and the error is gone.
Cannot proceed on running the test.
Suggested solution:
Per the release notes, the extend-expect
import path was removed. You need to change the import path to the following:
import '@testing-library/jest-dom'
@jgoz my bad, I missed that one. Thanks