Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • fireEvent
  • screen
  • waitFor
  • waitForElementToBeRemoved

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?

like image 985
amdev Avatar asked Jun 06 '26 14:06

amdev


1 Answers

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?

like image 175
amdev Avatar answered Jun 10 '26 09:06

amdev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!