testing-library / testing-library-recorder-extension

Testing Library Extension for Chrome DevTools Recorder
https://chrome.google.com/webstore/detail/testing-library-recorder/pnobfbfcnoeealajjgnpeodbkkhgiici?utm_source=github&utm_medium=referral
MIT License
144 stars 3 forks source link

Some userEvent calls are being incorrectly awaited #18

Closed charliematters closed 1 year ago

charliematters commented 1 year ago

I haven't looked through the whole list, but the userEvent.click method doesn't return a promise, but we might want to await the selector? e.g. await userEvent.click(screen.getByText("foo")) might be better as userEvent.click(await screen.findByText("foo"))

I don't know the intricacies of Chrome's recorder, so this might be unworkable, but it's worth checking which userEvent calls need await

nickmccurdy commented 1 year ago

As of user-event 14, all of these APIs are async. We need to target the latest version because recorder extensions can't access your package.json.

I also don't think we need to await the selectors because Chrome's recorder already has a waitForElement step that can be used when a test relies on async selectors. Adding await where it's not needed can cause race conditions and make tests slower with indirection.

charliematters commented 1 year ago

Ah, I'm a version behind - sorry!