- <ReactTestRenderer> [not] to contain [with all children] [with all wrappers] [with all classes] [with all attributes] <ReactElement|string>
- <ReactTestRenderer> [not] to contain [exactly] <ReactElement|string>
It's possible to check for a part of the subtree, without testing the entire returned tree. This allows you to test specific elements, without writing brittle tests that break when the structure changes.
Assuming the following component output
Notice that the extra
className="middle" in the
<span className="middle">two</span> is ignored,
in a similar way to the
to have rendered assertion.
You can override this behaviour by using
'to contain exactly', and
'to contain with all children'
The same thing applies to children for
'to contain' as for
'to have rendered'.