unexpected-react
unexpected-react copied to clipboard
validateDOMNesting(...): <tr> cannot appear as a child of <div>
This test
test('renders row', () => {
const Row = () => (
<tr>
<td>Hello</td>
</tr>
);
expect(
<Row />,
'to deeply render as',
<tr>
<td>Hello</td>
</tr>
);
});
Prints this warning:
console.error
Warning: validateDOMNesting(...): <tr> cannot appear as a child of <div>.
in tr (created by Row)
in Row
in StatelessWrapper
Workaround:
test('renders row', () => {
const Row = () => (
<tr>
<td>Hello</td>
</tr>
);
expect(
<table>
<tbody>
<Row />
</tbody>
</table>,
'to deeply render as',
<table>
<tbody>
<tr>
<td>Hello</td>
</tr>
</tbody>
</table>
);
});
Could unexpected-react somehow improve the situation by
- supressing such warnings
- or allowing to control how the rendered nodes are wrapped?