-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[Improved Fiber Support] Support Portals properly #1150
Comments
I can confirm that Portals don't work with Enzyme 3.0.0 (+ adapter for React 16), React 16.0.0 and Jest 21.2.0. See related test: https://github.com/WordPress/gutenberg/pull/2813/files#diff-6cf726110898b8679af57302917acb5dR279. |
I can be wrong but it looks like an issue in I tried this via jest and CRA: const Test = () => (
<div>
<h1>Hello</h1>
<Portal>Outside message</Portal>
</div>
)
const tree = renderer.create(<Test />).toJSON() Where The error message is
|
I don't know exactly if this is correct, but if I add case Portal:
return {
nodeType: 'class',
type: node.type,
props: (0, _object2['default'])({}, node.memoizedProps),
key: node.key,
ref: node.ref,
instance: node.stateNode,
rendered: childrenToTree(node.child)
}; my basic tests pass. I am not familiar at all with what should be returned from this switch block though... I am using latest version of react-modal in my app and with the react upgrade this issue surfaced in my tests. They are indeed in |
Hi there, any update? I just switched to react 16 and my tests are failing...
I would appreciate any hint, how to make them work again... |
@mayacode did you start using Portals as part of your switch? A react 15 codebase switched directly to 16 shouldn't be running into that error. |
I ran into the issue after upgrading react-modal, which does use portals if they are available |
@ljharb I upgraded react (from 15.4) and react-bootstrap (in the app is react-bootstrap's Modal in use, and I assume it uses portals, if available). In the end, I made everything else working, just tests are failing with |
thanks; if |
@ezhlobo, did you mean to use |
@omniroot thank you for noticing this. Yeah, I meant |
May one of the core contributors take a look at this PR? #1263 It should address this issue, but the PR owner needs help with the tests. |
Any update for all waiting people? I needed to comment a lot of tests... my coverage dropped down ;( |
@mayacode, you can always mock the behavior of |
I'm confused; testing Portals with enzyme and React 16 has never been possible; how could you have working tests that use them that need commenting out? |
Not exactly sure, but with react 15 and enzyme < 3, tests still worked, and when upgraded they totally fail. I wasn’t testing the portal itself per se, but a component that had one still was able to be rendered. This started happening to my project when I upgraded to latest enzyme and react 16 |
@kellyrmilligan right but with latest enzyme and react 15, do you still see a problem? Enzyme doesn't yet support Portals with React 16. |
I’ll give it a go. But I think we’re all just wanting this to at least not fail on that node type? This is blocking my upgrade path for the time being. |
correct, I branched off and just upgraded enzyme to latest, and this issue doesn't occur. again, i'm not sure here, but seems like a lot of folks would want portals to at least just not fail. there's even a PR for this issue. |
Of course, it should be fixed :-) just wanted to clarify that the issue only blocks upgrading to React 16, not upgrading to enzyme 3. |
@ljharb I have tests which are using react-bootstrap Modals, which are using react-overlays, which is using portals (if available). In a moment of upgrading react and react-bootstrap all Modal related tests started to fail. It blocks upgrading to react 16. |
gotcha; it seems like the combination of enzyme not supporting Portals, and react-overlays magically (instead of explicitly) using Portals, is the blocker. |
- add Portal support (enzymejs#1150, enzymejs#1263, enzymejs#1338, enzymejs#1345)
- add Portal support (enzymejs#1150, enzymejs#1263, enzymejs#1338, enzymejs#1345)
For the moment I've been mocking portals in the top of the test file like this: jest.mock('rc-util/lib/Portal') Obviously the |
I am not quite sure if these are supported yet or not. We need to add some tests. I also wonder if there are any APIs that might need to get created to assert on this or something?
The text was updated successfully, but these errors were encountered: