scrollIntoView is not a function
See original GitHub issueI’m running a test using a library (grommet
) that uses scrollIntoView
on an a
tag. jsdom
is throwing errors when hitting that line of code. I was able to get it to work by adding window.HTMLElement.prototype.scrollIntoView = function() {};
in my testHelper file to setup the tests, but I thought I’d report it to see if it’s something you want to fix.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:47
- Comments:17 (1 by maintainers)
Top Results From Across the Web
scrollIntoView() is not a function upon page load?
scrollIntoView is part of the DOM API, not jQuery. You need to run it on an Element, not a jQuery object: $('div#' +...
Read more >[Solved]-TypeError: scrollIntoView is not a function-Reactjs
If we want to unit test 'scrollIntoView' function in a react application using react testing library then we can mock the function using...
Read more >jQuery : scrollIntoView() is not a function upon page load?
jQuery : scrollIntoView() is not a function upon page load? [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] jQuery ...
Read more >Element.scrollIntoView() - Web APIs | MDN
The Element interface's scrollIntoView() method scrolls the element's ancestor containers such that the element on which scrollIntoView() is ...
Read more >javascript error: cannot read properties of null ... - You.com
Because jsdom does not implement scrollIntoView it will be undefined on elements provided by jsdom . Solution. The recommended approach from this Google...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
@QuantumInformation You can use this for the Jest:
Element.prototype.scrollIntoView = jest.fn();
hello, you can use window.HTMLElement.prototype.scrollIntoView = jest.fn()