New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Object [object global] has no method 'getSelection' #75
Comments
As odd as it is, I've encountered this bug too, the workaround I'm using is to manually blur the element in the teardown step of the test.
|
@PrototypeAlex thanks for the workaround |
also encountering this, @n1k0 - thanks for the title, this one was driving me crazy, I appreciate how easy it was to find this issue. |
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed. |
Seems like there is a workaround and this is specific to React tests? Also might have been fixed in jsdom. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This one's very odd. It seems you can't run two jest tests involving a component which uses the
focus()
method on a<textarea>
element. (I warned you, very odd.)Sample react component:
Sample test:
This one passes just fine:
Now update the test suite adding another test:
This new suite fails:
Side note, after investigating a little, it seems that
ReactDOMSelection
relies onwindow.getSelection
for some stuff, but that jsdom doesn't support it (hence the error we get.)Maybe you should start thinking of implementing required polyfills in jest/jsdom to match modern environments? (yeah, I know, tedious.)
Note: I've titled this bug with the exception string to help indexing this issue for people searching for the exact error message, feel free to rephrase if needed.
The text was updated successfully, but these errors were encountered: