Testing
Shallow Renderer
When writing unit tests for React, shallow rendering can be helpful. Shallow rendering lets you render a component “one level deep” and assert facts about what its render method returns, without worrying about the behavior of child components, which are not instantiated or rendered. This does not require a DOM.
For example, if you have the following component:
Then you can assert:
Shallow testing currently has some limitations, namely not supporting refs.
Last updated
Was this helpful?