react-testing-libraryuser-event

Cant find setup() on userEvent


I am trying to use the user-event utility in testing library as described here :

https://testing-library.com/docs/user-event/intro

Unfortunatley when I try and call the setup function

userEvent.setup()

My IDE says that it cannot be found :

enter image description here

Why is this happening?

My import in my file looks like this :

import userEvent from '@testing-library/user-event'

And my package dependencies look like this :

"@testing-library/dom": "^8.11.3",
"@testing-library/jest-dom": "5.7.0",
"@testing-library/react": "^12.1.2",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.5.0",

Solution

  • The userEvent.setup() API is added in v14.0.0

    There is a note in the doc user-event/intro

    These docs describe user-event@14.