-
-
Notifications
You must be signed in to change notification settings - Fork 2k
html() does not work on React components which return an array of elements #1178
Copy link
Copy link
Closed
Description
Hi!
I have a fairly simple component that takes advantage of React 16 and renders multiple elements, <p> to be precise. It changes a string or an array of strings to a paragraph or an array of paaragrahps, respectively. One of my test cases is like so:
const component = (
<Paragraph>['Test 1', 'Test 2', 'Test 3']</Paragraph>
);
const html = mount(component).html();
expect(html).toBe('<p>Test 1</p><p>Test 2</p><p>Test 3</p>');I'd expect that in this case .html() would return either a string as provided above in my expect().toBe() or an array of three strings. Instead, this ends in a following error:
Trying to get host node of an array
at _nodeToHostNode (../node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:172:11)
at ReactSixteenAdapter.nodeToHostNode (../node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:421:16)
at ReactWrapper.<anonymous> (../node_modules/enzyme/build/ReactWrapper.js:823:30)
at ReactWrapper.single (../node_modules/enzyme/build/ReactWrapper.js:1534:25)
at ReactWrapper.html (../node_modules/enzyme/build/ReactWrapper.js:820:21)
at Object.<anonymous> (components/_common/__tests__/Paragraph.jsx:141:50)
Thanks in advance!
Reactions are currently unavailable