You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe
I ran into an issue testing React-Bootstrap's Offcanvas component, which uses Modal under the hood. My test fails when asserting that the component is closed after pressing the Esc key:
it('closes the drawer when the esc key is pressed',async()=>{render(<Offcanvas/>);expect(screen.queryByRole('dialog')).toBeInTheDocument();awaituserEvent.keyboard('{Escape}');expect(screen.queryByRole('dialog')).not.toBeInTheDocument();});
Is your feature request related to a problem? Please describe
I ran into an issue testing React-Bootstrap's
Offcanvas
component, which usesModal
under the hood. My test fails when asserting that the component is closed after pressing the Esc key:Modal
usesKeyBoardEvent.keyCode
to check whether the Esc key has been pressed. However,KeyboardEvent.keyCode
is deprecated and no longer supported in@testing-library/user-event
.Describe the solution you'd like
Given that
KeyboardEvent.keyCode
is deprecated, it seems like a good idea to add support forKeyboardEvent.key
eg:This would solve my particular problem, but more generally future-proof this library if and when browsers drop support for
KeyboardEvent.keyCode
.Describe alternatives you've considered
Testing Library suggests patching the key events as a workaround:
The text was updated successfully, but these errors were encountered: