reactjsunit-testingreact-testing-librarytesting-library

Module '"@testing-library/react"' has no exported member 'waitFor'


Since today, I started to get this type error and bunch of others regarding "@testing-library/react"

I followed a similar GitHub issue and they are seem to be relevant but not an answer of why this might happen!

Things that I'm getting this error on are:

I Also tried using this page it helped a bit but still i really have no idea where to get waitFor, waitForElementToBeRemoved and others that might needed. they are coming from @testing-library/react but why typescript gives me that error I absolutely have no idea!

I'm using pnpm and my pkg versions are latest ones:

"@testing-library/jest-dom": "^6.0.0",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.4.3",

Why is this happening?


Solution

  • So after investigating this issue a lot, I figured out a solution from some other projects of mine which was exactly using the same pkgs but they did not have any error.

    So I clicked on the type definition of waitFor in there and started to chase that within node_modules directory of that project.

    after a while, i did notice that waitFor comes from @testing-library/dom and i wondered if i have that package installed or not!

    soon after I installed that package, it fixed my issue BUT I wonder what this pkg @testing-library/jest-dom doing then?