-
Notifications
You must be signed in to change notification settings - Fork 470
Screen Export: Should it include the debug method? #417
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
Comments
Hi @jkdowdle, It's already supported: import {logDOM} from '@testing-library/react'
logDOM() // logs out document.body Though I can see the value of having it on Thoughts from anyone else? |
I did not think of it before, but now I am sure I would unconsciously go and try to get |
I'm not opposed to adding it, but I'd like to hear arguments for/against. |
Enzyme has a debug method for nodes, might make it easier to migrate nog screen did too |
I vote Yes as this would make it a lot easier to report on debug in the testing lint rule. Actually for that matter why not Make it a top level export? I'd even support a breaking change to remove it from the results as that makes it quite tricky to lint when used with Custom render functions. For note, the goal of the no debug lint rule is to keep it out of CI, and only use it locally temporarily when Debugging |
@benmonro That sounds like the best argument so far for only allowing the top level export for the debug method, if I understood correctly. I personally haven't used the eslint rules yet for @testing-library but I'd like to start. Thank you |
@jkdowdle there's also the jest-Dom lint plugin that I wrote. 😎 |
I assumed based on experience with debug method returned from render that I could either do Personally I like the syntax of import { debug } from "@testing-library"
render();
debug(screen); |
The benefit of putting it on I think I'm in favor of this. Anyone wanna PR it? |
@kentcdodds I would agree! and I'd love to try to do the PR |
Go for it 👍 |
|
Great job on this! Just noting to clarify for future readers that it seems it was released with |
Uh oh!
There was an error while loading. Please reload this page.
Describe the feature you'd like:
I was just trying out the screen object to power the queries of my tests and the first thing I did was try using the debug method, expecting it to be there like from the object you get back from render in
'@testing-library/react'.
And I noticed that it was not available. I would love to submit a PR to add it, but before I went looking around on how to do that I thought I would double check and make sure that that was not a conscious decision to leave out. Maybe some constraints on the difficulty of adding it or something like that.
Suggested implementation:
Describe alternatives you've considered:
We can continue getting the debug method off the returned object from rendering.
Or, as was mentioned bellow, use the logDOM export.
Teachability, Documentation, Adoption, Migration Strategy:
This would increase the surface area by a little bit, but since screen was already added, it would not be that much more to add. I think users, like myself, would expect it to be there.
I want to thank all the maintainers, keep up the great work!
The text was updated successfully, but these errors were encountered: