TypeError: range.cloneRange is not a function after updating to v.14
See original GitHub issueReproduction example
https://pastecode.io/s/n6p0zq9q
Prerequisites
- Update to user-event v.14
- Add async/await for tests with user-event usage.
- Run test
Expected behavior
Test should pass - it did with v.13.
Actual behavior
Test fails with TypeError: range.cloneRange is not a function
TypeError: range.cloneRange is not a function
at mousedownDefaultBehavior (../../node_modules/@testing-library/user-event/dist/index.cjs:2441:32)
at down (../../node_modules/@testing-library/user-event/dist/index.cjs:2309:7)
at pointerPress (../../node_modules/@testing-library/user-event/dist/index.cjs:2248:19)
at pointerAction (../../node_modules/@testing-library/user-event/dist/index.cjs:2471:33)
User-event version
14.0.4
Environment
Testing Library framework:
"@testing-library/dom": "8.12.0",
"testing-library/jest-dom": "5.16.3",
"@testing-library/react": "12.1.4",
"@testing-library/react-hooks": "7.0.2",
"@testing-library/user-event": "14.0.4",
JS framework: react@17.0.2
Test environment: jest@27.5.1
Additional context
node v.12
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:18 (6 by maintainers)
Top Results From Across the Web
Errors when updating @testing-library/user-event to v.14
TypeError : range.cloneRange is not a function. All my tests were passing before the library updates, now all failing.
Read more >Range.cloneRange() - Web APIs - MDN Web Docs
The Range.cloneRange() method returns a Range object with boundary points identical to the cloned Range.
Read more >UNPKG - @testing-library/user-event
1, var __defProp = Object.defineProperty;. 2, var __defProps = Object.defineProperties;. 3, var __getOwnPropDescs = Object.getOwnPropertyDescriptors;.
Read more >DOM Standard
When dispatched in a tree, invoking this method prevents event from reaching any objects other than the current object. ✓MDN.
Read more >Uncaught TypeError | Is Not A Function | Solution - YouTube
Have you encountered an error like:- Uncaught TypeError - Some selector is not a function - jQuery is not a function - owlCarousel...
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 Free
Top 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
I ran into the same problem.
In my case the problem was not that the environment didn’t implement
Range.cloneRange()but the fact that I was overwriting it in my local test setup (global.document.createRange = () => ({ ... })), which was some code from before my test environment implementedRange. Removing that from my setup fixed the issue for me.I am having the same issue but with
createRange