react-testing-library icon indicating copy to clipboard operation
react-testing-library copied to clipboard

Support `beforeInput` event

Open zombieJ opened this issue 3 years ago • 4 comments

Describe the feature you'd like:

fireEvent support beforeInput event

Suggested implementation:

N/A

Describe alternatives you've considered:

N/A

Teachability, Documentation, Adoption, Migration Strategy:

N/A

zombieJ avatar Nov 15 '22 03:11 zombieJ

@zombieJ Could you please describe beforeInput in some detail so it can be investigated further.

hjonasson avatar Dec 06 '22 00:12 hjonasson

It doesn't look like this bug report has enough info for one of us to reproduce it.

Please provide a CodeSandbox (https://react.new), or a link to a repository on GitHub.

Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

eps1lon avatar Dec 06 '22 20:12 eps1lon

I've stumbled over this issue too.

Using jest, jest-environment-jsdom and @testing-library/react to test an input element that is hooked to onBeforeInput and changes the target's value.

A minimal live example https://codesandbox.io/s/dank-snowflake-ott8rx

And a repo with the problematic test https://github.com/gsuntres/testing-library-bug

gsuntres avatar May 19 '23 01:05 gsuntres

Keep in mind that React aren't actually using the beforeinput event, so even if we add support for that, it won't work in RTL: https://github.com/facebook/react/issues/11211. I'll look up what needs to be added to support that specific event in DTL (but again, it won't solve the issue for React Testing Library).

MatanBobi avatar Nov 06 '23 10:11 MatanBobi