activeElement might change during userEvent.type causing runtime errors
See original GitHub issue@testing-library/user-event
version: >= 11.1.0@testing-library/dom
version: 5.10.1- Testing Framework and version: jest@26.0.1
- DOM Environment: jsdom jest-environment-jsdom-global@2.0.2
- node: 13.7.0
What you did:
Using userEvent.type
. We have like > 1k tests which mostly use fireEvent
but slowly upgrading to userEvent
. All run fine, execept for one I encountered while updating our dependencies.
As a tmp fix one can use fireEvent.change
.
What happened:
I narrowed it down to start with the release of https://github.com/testing-library/user-event/releases/tag/v11.1.0
TypeError: Cannot read property 'length' of undefined
at calculateNewValue (node_modules/@testing-library/user-event/dist/type.js:312:43)
at typeCharacter (node_modules/@testing-library/user-event/dist/type.js:366:43)
at typeImpl (node_modules/@testing-library/user-event/dist/type.js:230:29)
at node_modules/@testing-library/user-event/dist/type.js:20:14
at node_modules/@testing-library/react/dist/pure.js:58:16
Reproduction:
Problem description:
We currently have 90 occurrences for await userEvent.type(
in our codebase, yet only a single one has this issue. I don’t understand (yet) what could cause this.
But I figured out the activeElement
is always the body, so calling currentValue()
will be undefined, as body
has no value prop.
I will provide more details if I find more.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
React Testing Library - testing in isolation and userEvent error
I noticed that element.ownerDocument.activeElement is null wasAnotherElementFocused is true and so it throws the error. The first time I run the ...
Read more >user-event v13 - Testing Library
Fires a tab event changing the document.activeElement in the same way the browser does. Options: shift (default false ) can be true or...
Read more >5. SMIL 3.0 Timing and Synchronization - W3C
A document containing SMIL Timing and Synchronization elements and attributes is referred to as a host document. As this module is used in...
Read more >JavaScript - Royal Icing
We can do this by running requestAnimationFrame() ourself. However, when testing React we need to ensure anything that could change state is ...
Read more >Bug List - Bugzilla - allizom.org
ID Summary Product Comp Assigne...
1352852 "dragstart" requires setting dataTransfer Core DOM: Events nobody
1480664 'mouseout' event fires prematurely for element Core DOM: Events nobody
1493530...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am still encountering this issue due to portals. It gives me errors like:
v12.0.14 addressed our issues, no longer seeing this happen!