Skip to content
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

The React18 support in Component Testing doesn't work #23081

Closed
joshwooding opened this issue Aug 3, 2022 · 7 comments · Fixed by #23204
Closed

The React18 support in Component Testing doesn't work #23081

joshwooding opened this issue Aug 3, 2022 · 7 comments · Fixed by #23204
Assignees
Labels
CT Issue related to component testing type: bug

Comments

@joshwooding
Copy link
Contributor

joshwooding commented Aug 3, 2022

Current behavior

Currently when running a CT using the new entry "cypress/react18" I get the following error:

image

Which is thrown from

lastMountedReactDom.unmountComponentAtNode(el)
because the lastMountedReactDom is react-dom/client which only exports createRoot and hydrateRoot (https://github.com/facebook/react/blob/9fcaf88d58cfd942e2fdd303ae8291dbf4828969/packages/react-dom/client.js#L25)

Desired behavior

No response

Test code to reproduce

I can't provide a reproduction at the moment but will provide one soon. Using the react18 entry in a CT suite should cause it immediately.
https://github.com/joshwooding/cypress-react18-repro

Cypress Version

10.4.0

Other

No response

@cypress-bot cypress-bot bot added the stage: investigating Someone from Cypress is looking into this label Aug 3, 2022
@joshwooding
Copy link
Contributor Author

joshwooding commented Aug 3, 2022

Just an update you need two tests in the spec to encounter the error. I've added the reproduction above @rockindahizzy.

@rockindahizzy
Copy link
Contributor

Just an update you need two tests in the spec to encounter the error. I've added the reproduction above @rockindahizzy.

Thanks for the reproduction, @joshwooding!

@lmiller1990
Copy link
Contributor

lmiller1990 commented Aug 3, 2022

Uh oh, I guess we forgot pass through the React 18 specific unmount:

export function unmount (options: UnmountArgs = { log: true }) {
const internalOptions: InternalUnmountOptionsReact18 = {
// type is ReturnType<typeof ReactDOM.createRoot>
unmount: (): boolean => {
root.unmount()
return true
},
}
return makeUnmountFn(options, internalOptions)

The main test suite (which is huge) only runs against cypress/react right now, the smaller one for React 18 is not doing two mount in a single test: https://github.com/cypress-io/cypress/tree/develop/system-tests/project-fixtures/react/src

Big oversight, let's fix this and ship a patch in the next release. This makes react18 basically useless as-is - we haven't actually documented it yet, so I'm not sure if we can push our a mid sprint release, but maybe we can - let's see how it goes.

@cypress-bot cypress-bot bot added stage: routed to ct and removed stage: investigating Someone from Cypress is looking into this labels Aug 4, 2022
@mjhenkes mjhenkes added type: bug stage: investigating Someone from Cypress is looking into this CT Issue related to component testing and removed stage: routed to ct labels Aug 4, 2022
@cypress-bot cypress-bot bot added stage: in progress and removed stage: investigating Someone from Cypress is looking into this labels Aug 8, 2022
@dartess
Copy link
Contributor

dartess commented Aug 8, 2022

Hey, for some reason I couldn't find this issue through a github search. It was only by chance that I was able to find it with my eyes. Maybe this comment will help the following seekers:

TypeError: lastMountedReactDom.unmountComponentAtNode is not a function

@lmiller1990
Copy link
Contributor

PR is here to fix it: https://github.com/cypress-io/cypress/pull/23204/files

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 10, 2022

The code for this is done in cypress-io/cypress#23204, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Aug 15, 2022

Released in 10.5.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v10.5.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Aug 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CT Issue related to component testing type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants