Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow depth option when serializing mounted wrappers #169

Open
iamogbz opened this issue Jun 6, 2020 · 0 comments
Open

Allow depth option when serializing mounted wrappers #169

iamogbz opened this issue Jun 6, 2020 · 0 comments

Comments

@iamogbz
Copy link

iamogbz commented Jun 6, 2020

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants