Skip to content

Commit

Permalink
[Fix] mount: text(): null nodes return null
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jun 29, 2018
1 parent 7fcbb35 commit d114e68
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/enzyme/src/ReactWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,10 @@ class ReactWrapper {
*/
text() {
const adapter = getAdapter(this[OPTIONS]);
return this.single('text', n => adapter.nodeToHostNode(n).textContent);
return this.single('text', (n) => {
const node = adapter.nodeToHostNode(n);
return node && node.textContent;
});
}

/**
Expand Down

2 comments on commit d114e68

@jamesvclements
Copy link

@jamesvclements jamesvclements commented on d114e68 Jul 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When can we expect a release of enzyme-adapter-react-16 to use [email protected]? Looks like it's still on 1.3.0

@ljharb
Copy link
Member Author

@ljharb ljharb commented on d114e68 Jul 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it's ready. See #1723 as well.

Please sign in to comment.