type() is slow
Testing Library is the current recommended way to unit test React code. By itself it works great and does a lot of the heavy lifting for you. Its sibling library
@testing-library/user-event which can be used to trigger click events, typing etc is still a bit green though.
type() command is great for simulating user input letter-by-letter, however it has some issues: without a delay, it is non-deterministic, meaning you’ll need to manually wait for the UI to update in certain cases. On the flip side, even if you use
Average time spent: type(target, text) (210ms)
Unless you necessarily need the letter-by-letter input to correctly test behavior, the
paste() command will save you considerable time on your test runs:
Average time spent: paste(target, text) (20ms)
For the time being, the library maintainers don’t see this as an issue so using the above workaround seems like the best option.