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: range.cloneRange is not a function after updating to v.14 #902
Comments
Please create a reproducible example of the bug. If your reproduction contains a component, you'll need to include that. This is probably an issue with the environment not implementing |
I ran into the same problem. In my case the problem was not that the environment didn't implement |
I am having the same issue but with
|
This was exactly what caused the issue in my case - thanks @MarijNefkens! |
I'm facing the same issue with v14. @osamajandali did you manage to solve your problem? |
Same issue: I am getting
|
Please try upgrading your DOM implementation and check for mocked methods on it as #902 (comment) suggests. |
I'm also seeing the same issue w/ these versions. But note that I'm using vitest/happy-dom. Took a look at the happy-dom implementation and there are no mocks for that function. See also: capricorn86/happy-dom#450
|
The issue still exists on v14 of user-event, and I don't have this mocked method. @ph-fritsche please reopen this issue, as a problem still exists. |
@Zemelia This is not an issue with |
@ph-fritsche Do such requirements exist somewhere in docs? |
I'd argue that it's fair to assume a DOM according to specs that roughly matches what is implemented in modern browsers to be implied. |
@ph-fritsche Thank You! |
@Zemelia |
@ph-fritsche But user-event@14 with react-dom@17 have issues mentioned above, like user-event@13 works well with that react and react-dom version |
@Zemelia As suggested above: Upgrade your DOM implementation or use a different one that implements those interfaces according to specs. If you have trouble identifying which part of your setup is responsible for the DOM, we've got a Discord server where you might find someone to help you with this. |
As far as the DOM is concerned, there seem to be only two games in town: jsdom and happy-dom.
Note: and this is a very important note, the react-testing-library team actively recommends using happy-dom... Because it is super fast.
On Jun 3, 2022 11:38 AM, Philipp Fritsche ***@***.***> wrote:
@Zemelia<https://github.com/Zemelia> ***@***.*** has no issue, your DOM implementation has an issue. This has nothing to do with react-dom
because it does not implement the DOM - neither in ***@***.*** nor any other version.
***@***.*** doesn't interact with implementations of Selection and Range, thus there is no error if you use it with a DOM implementation that doesn't implement those interfaces.
As suggested above: Upgrade your DOM implementation or use a different one that implements those interfaces according to specs. If you have trouble identifying which part of your setup is responsible for the DOM, we've got a Discord server<https://discord.gg/testing-library> where you might find someone to help you with this.
—
Reply to this email directly, view it on GitHub<#902 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAGAGMKINB4OTIK7AEYZG3LVNIYGZANCNFSM5SPJWDPQ>.
You are receiving this because you commented.Message ID: ***@***.***>
|
@ph-fritsche Understand, many thanks for the explanation! |
- removed the mocked document.createRange. This isn't necessary anymore. See testing-library/user-event#902 - awaited userEvent calls, removed unnecessary act blocks - fixed type errors around icon types - note: there are still act warnings for some tests in the specs, even some not involving any state updates (style snapshots). Probably points to unwanted rerenders. Added a fixme comment.
- removed the mocked document.createRange. This isn't necessary anymore. See testing-library/user-event#902 - awaited userEvent calls, removed unnecessary act blocks - fixed type errors around icon types - note: there are still act warnings for some tests in the specs, even some not involving any state updates (style snapshots). Probably points to unwanted rerenders. Added a fixme comment.
* Upgrade user-event to v14 * Address breaking changes in Popover spec - removed the mocked document.createRange. This isn't necessary anymore. See testing-library/user-event#902 - awaited userEvent calls, removed unnecessary act blocks - fixed type errors around icon types - note: there are still act warnings for some tests in the specs, even some not involving any state updates (style snapshots). Probably points to unwanted rerenders. Added a fixme comment. * Address breaking changes in useEscapeKey - exposed the renderHook method from @testing-library/react, meant to replace the onoe from @testing-library/react-hooks, which isn't compatible with React 18. For migration purposes, I'm naming it newRenderHook--I'll remove the legacy method and rename the new one after all specs have been migrated - awaited userEvent calls and removed unnecessary act blocks * Fix accessibility error in ToastContext The live region wrapping toasts should not be a ul, because uls son't allow the status role (likely because it overrides list semantics anyways. Switched for divs. Found through a better axe test * Migrate user-event in NotificationToast spec - await userEvent method calls - added a new render helper to render a component tree including the ToastProvider, to reduce test boilerplate when testing business logic - improved the accesibility test to cover an actual document with a toast instead of the toast UI in isolation * WIP: upgrade user-event in SidePanel components - awaited userEvent methods and removed unnecessary act blocks - migrated useSidePanel to newRenderHook and removed unnecessary actHook blocks - added ariaHideApp=false to default test props in SidePanelContext to silence react-modal warning about the undefined app element - set up userEvent with delay=null in SidePanelContext to address this issue: testing-library/user-event#833 - TODO: two tests using userEvent.keyboard() are still failing. Marked as todo. - TODO: there are two act() warnings left (likely from before) when running `yarn test sidepanel` (all SidePanel-related specs) * Patch keyCode event in SidePanel spec This also adds comments on accessibility tests that inconsistently trigger axe warnings. Will be investigated and addressed separately. * Migrate Button, RadioButton, RadioButtonGroup, Header Awaited userEvent calls. * Migrate remaining input components Checkbox, CurrencyInput, Selector. Awaited userEvent method calls * Migrate notification components Awaited userEvent method calls * Migrate modal components - awaited userEvent method calls - set up userEvent with delay=null in ModalContext spec (same as in SidePanelContext) * Migrate more components Hamburger, Pagination, PageList, UtilityLinks, useClickOutside. Awaited userEvent method calls. Does not include the migration to new renderHook for useClickOutside, will be handled separately. * Use userEvent with delay=null in ToastProvider spec Same as in the ModalProvider and SidePanelProvider * Migrate userEvent in useAutoExpand - awaited method calls - migrated {space} to { } - TODO: migrate to the new renderHook, will be addressed separately * Migrate userEvent in remaining components - await method calls - fix some TS errors * Migrate useStep to renderHook from RTL - replace imports - replace removed waitForNextUpdate by a more explicit waitFor - remove tests covering error logic. Error testing was removed in the renderHook port to RTL and we're not covering this in other components, so I think it's fine to remove. See testing-library/react-testing-library#991 for more context * Migrate renderHook from RHTL to new RTL implementation See testing-library/react-testing-library#991 for context. - replaced import of renderHook to newRenderHook (will be renamed in a follow-up commit) - replaced actHook by act - (edge cases were handled in earlier commits) * Rename newRenderHook to renderHook * Await remaining userEvent promises Not sure why these specs passed locally before * Address review comment
Reproduction example
https://pastecode.io/s/n6p0zq9q
Prerequisites
Expected behavior
Test should pass - it did with v.13.
Actual behavior
Test fails with
TypeError: range.cloneRange is not a function
User-event version
14.0.4
Environment
Testing Library framework:
JS framework:
react@17.0.2
Test environment:
jest@27.5.1
Additional context
node v.12
The text was updated successfully, but these errors were encountered: