-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Labels
Description
Description
Sometimes you have to mount a component for it too fully render e.g. in the case of functional components. However when snapshotting the rendered enzyme wrapper, you do not need the entire tree.
Currently there are two options deep
and shallow
. Deep does the entire tree which most times is not what you want to snapshot. Shallow only serializes the initial component instance.
Adding the ability to specify depth would be great for cases where you need to only snapshot to a certain level of granularity.
Depth | Description |
---|---|
0 |
Equivalent to mode: shallow |
1 |
Equivalent to shallow render |
.. |
|
Infinity |
Equivalent to mode: deep |
Note
Workarounds do exist e.g.
const serialized = toJson(wrapper.find(Base).children(), { mode: 'shallow' })
expect(serialized).toMatchSnapshot()
mrobb-twitch