Socket
Socket
Sign inDemoInstall

@testing-library/user-event

Package Overview
Dependencies
23
Maintainers
15
Versions
199
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @testing-library/user-event

Fire events the same way the user does


Version published
Weekly downloads
7.3M
decreased by-16.05%
Maintainers
15
Install size
425 kB
Created
Weekly downloads
 

Package description

What is @testing-library/user-event?

The @testing-library/user-event package is a library built on top of @testing-library/dom that simulates user interactions with the DOM. It allows developers to write tests that mimic user behavior in a way that is consistent with how a user would use a web application. This helps ensure that tests are realistic and that the application will work as expected when real users interact with it.

What are @testing-library/user-event's main functionalities?

Typing text into an input element

Simulates typing text into an input field or other element that can receive input.

userEvent.type(screen.getByRole('textbox'), 'Hello, World!')

Clicking elements

Simulates a click event on a button, link, or any other clickable element.

userEvent.click(screen.getByText('Submit'))

Selecting options in a select element

Simulates selecting an option from a dropdown select element.

userEvent.selectOptions(screen.getByRole('combobox'), 'optionValue')

Uploading files

Simulates a file upload interaction on an input of type file.

userEvent.upload(screen.getByLabelText('Upload'), file)

Tabbing through elements

Simulates tabbing through focusable elements on the page.

userEvent.tab()

Other packages similar to @testing-library/user-event

Readme

Source

user-event

dog

Fire events the same way the user does


Read The Docs



Build Status Code Coverage version downloads MIT License All Contributors PRs Welcome Code of Conduct Discord

Watch on GitHub Star on GitHub Tweet

The problem

From testing-library/dom-testing-library#107:

[...] it is becoming apparent the need to express user actions on a web page using a higher-level abstraction than fireEvent

The solution

user-event tries to simulate the real events that would happen in the browser as the user interacts with it. For example userEvent.click(checkbox) would change the state of the checkbox.

The more your tests resemble the way your software is used, the more confidence they can give you.

Issues

Looking to contribute? Look for the Good First Issue label.

🐛 Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

See Bugs

💡 Feature Requests

Please file an issue to suggest new features. Vote on feature requests by adding a 👍. This helps maintainers prioritize what to work on.

See Feature Requests

❓ Questions

For questions related to using the library, please visit a support community instead of filing an issue on GitHub.

Contributors

We most sincerely thank the people who make this project possible. Contributions of any kind are welcome! 💚

License

MIT

Keywords

FAQs

Last updated on 29 Dec 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc