diff --git a/packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js b/packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js index fecc1024a..856df857b 100644 --- a/packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js +++ b/packages/enzyme-adapter-react-16/src/ReactSixteenAdapter.js @@ -87,8 +87,21 @@ function toTree(vnode) { switch (node.tag) { case HostRoot: // 3 return childrenToTree(node.child); - case HostPortal: // 4 - return childrenToTree(node.child); + case HostPortal: { // 4 + let renderedNodes = flatten(nodeAndSiblingsArray(node.child).map(toTree)); + if (renderedNodes.length === 0) { + renderedNodes = [node.memoizedProps.children]; + } + return { + nodeType: 'portal', + type: node.type, + props: { ...node.memoizedProps }, + key: ensureKeyOrUndefined(node.key), + ref: node.ref, + instance: null, + rendered: renderedNodes, + }; + } case ClassComponent: return { nodeType: 'class',