diff --git a/packages/react-test-renderer/src/ReactTestRenderer.js b/packages/react-test-renderer/src/ReactTestRenderer.js
index 516511ca0c94a..036fe1885ad5a 100644
--- a/packages/react-test-renderer/src/ReactTestRenderer.js
+++ b/packages/react-test-renderer/src/ReactTestRenderer.js
@@ -338,6 +338,8 @@ function toTree(node: ?Fiber) {
};
case HostText: // 6
return node.stateNode.text;
+ case Fragment: // 10
+ return toTree(node.child);
default:
invariant(
false,
diff --git a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js
index e077fd6e58ece..d39311986518d 100644
--- a/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js
+++ b/packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js
@@ -530,6 +530,28 @@ describe('ReactTestRenderer', () => {
);
});
+ it('toTree() handles nested Fragments', () => {
+ const Foo = () => (
+
+ foo
+
+ );
+ const renderer = ReactTestRenderer.create();
+ const tree = renderer.toTree();
+
+ cleanNodeOrArray(tree);
+
+ expect(prettyFormat(tree)).toEqual(
+ prettyFormat({
+ nodeType: 'component',
+ type: Foo,
+ instance: null,
+ props: {},
+ rendered: 'foo',
+ }),
+ );
+ });
+
it('toTree() handles null rendering components', () => {
class Foo extends React.Component {
render() {