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

Request: add option to debug() to ignore props #960

Closed
finnigantime opened this issue May 31, 2017 · 2 comments
Closed

Request: add option to debug() to ignore props #960

finnigantime opened this issue May 31, 2017 · 2 comments

Comments

@finnigantime
Copy link
Contributor

It would be nice to have an option in debug() that skips printing props in the debug string.

For large components with many props spread across the different elements in the render tree, if you want to focus on the structure of the tree when debugging, this option can hide all props so you can focus just on the hierarchy of elements.

This is particularly useful if matchesElement() is used in a test that fails. matchesElement() just returns a boolean that doesn't show the diff of what didn't match when it fails. Using debug() is the best way to debug this. However, matchesElement() ignores props in its comparison, so it would be nice to have a variant of debug() that also ignores props so that it can be used while debugging to figure out exactly what is the diff between actual and expected values that caused matchesElement() to fail.

@ljharb
Copy link
Member

ljharb commented May 31, 2017

Seems reasonable; but it might be tricky in that I think in debug we just pass through what React gives us.

@finnigantime
Copy link
Contributor Author

finnigantime commented May 31, 2017

Took a stab at it (wrote the code before I filed this issue), let me know what you think.

Also, this might be useful in enzymejs/enzyme-matchers#95

@ljharb ljharb closed this as completed in 18b94f3 Jun 12, 2017
ljharb added a commit that referenced this issue Jun 12, 2017
Merge pull request #961 from finnigantime/finnigantime/ignoreProps

Fixes #960.
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