-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow debug
to accept same args at prettyDOM
#580
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 debug
to accept same args at prettyDOM
#580
Comments
Hi there @hottmanmichael, Thanks for the issue. I'm good with your first suggestion :) Would you like to make a pull request? |
@kentcdodds Yep! Would be happy to 👍 Thanks for the quick reply! This'll be my first open source contribution |
Awesome! |
Hope you don't mind that I was working on things today and decided to implement this myself. Thanks for the idea though! |
@all-contributors please add @hottmanmichael for ideas |
I've put up a pull request to add @hottmanmichael! 🎉 |
🎉 This issue has been resolved in version 9.5.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Describe the feature you'd like:
When using the
debug
wrapper in a test, it would be useful to be able to pass additionalprettyDOM
arguments through fromdebug
An example use case is being able to extend the number of lines that
prettyDOM
allows without needing to specify this inenv
prior to running the tests or needing to useprettyDOM
directlyExample:
I'd be happy to implement this feature, however just curious if there was a specific reason why this was not implemented on the first pass of
debug
- My team is familiar with usingdebug
for printing out the DOM and we don't often useprettyDOM
, and since this wrapper already exists as an api of therender
method, allowing users to usedebug
as the default api makes sense to meSuggested implementation:
1. First Suggestion:
Additional arguments could be forwarded through
debug
and passed intoprettyDOM
in this chunk of codereact-testing-library/src/pure.js
Lines 63 to 68 in 89d11b0
2. Second Suggestion
Keep the implementation of
debug
the same and add an additional method that always prints thebaseElement
and allows the user to forward args to prettyDOM - I'm not a big fan of this solution, but 99% of time I've found myself callingdebug()
without any arguments with the assumption that I wasn't able to passdebug(someElement)
as the first argument - so being able to calldebug(maxLines)
without specifying the debugged element might be niceDescribe alternatives you've considered:
DEBUG_PRINT_LIMIT=10000 npm test
however when running jest in--watch
mode, this requires us to kill the test runner, update the print limit, then rerun tests which isn't super painful, but adding this inline would be fasterprettyDOM
directly from@testing-library/dom
, however it's not immediately clear from the docs whether we should be passing incontainer
,asFragment()
, orbaseElement
into this method - Also, sincedebug
is already a wrapper on top of prettyDOM, it makes sense to be able to pass the same args IMOprettyDOM
is thatdebug
wrapsprettyDOM
in a console.log, whereasprettyDOM
requires you to callprettyDOM
within a console.log, which makes using the two apis interchangeably potentially confusingTeachability, Documentation, Adoption, Migration Strategy:
Docs would stay very much the same, only adding a link to
prettyDOM
from https://testing-library.com/docs/react-testing-library/api#debug and ensure that it's clear the user can forward prettydom arguments fromdebug
The text was updated successfully, but these errors were encountered: