You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importReact,{Component}from'react';import{createPortal}from'react-dom';importEnzyme,{mount,shallow}from'enzyme';importAdapterfrom'enzyme-adapter-react-16';Enzyme.configure({adapter: newAdapter()});classTestextendsComponent{render(){returncreatePortal(<div>Test</div>,document.createElement('div'));}}describe('Test',()=>{it('Should be rendered',()=>{// MountletTestComponentMount=mount(<Test/>);console.log(TestComponentMount.debug());// ShallowletTestComponentShallow=shallow(<Test/>);console.log(TestComponentShallow.debug());});});
Current behavior
console.log test.js:23 // Mount result
<Test>
<div>
Test
</div>
</Test>
console.log test.js:27 // Shallow result
<undefined />
Expected behavior
I think Enzyme should use the shallow method correctly with Portals. Mount is not an universal method. If we have a component with not a simple child (eg, with some providers - intl, redux etc.), we can't mount the parent component. And we have to use the shallow method.
Your environment
Mac OS Sierra 10.13.3
Node Version 8.9.4
NPM Version 5.6.0
Yarn Version 1.3.2
API
shallow
mount
render
Version
library
version
Enzyme
3.2.0
React
16.2.0
Adapter
enzyme-adapter-react-16
The text was updated successfully, but these errors were encountered:
I think it seems to be hard to support Portal in enzyme's shallow because React ShallowRenderer doesn't support Portal.
So I guess we should add Portal support into React ShallowRenderer in order to do this.
Current behavior
Expected behavior
I think Enzyme should use the
shallow
method correctly with Portals.Mount
is not an universal method. If we have a component with not a simple child (eg, with some providers - intl, redux etc.), we can't mount the parent component. And we have to use theshallow
method.Your environment
Mac OS Sierra 10.13.3
Node Version 8.9.4
NPM Version 5.6.0
Yarn Version 1.3.2
API
Version
Adapter
The text was updated successfully, but these errors were encountered: