Skip to content

Screen Export: Should it include the debug method? #417

@jkdowdle

Description

@jkdowdle

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'.

import React from 'react'
import { screen } from '@testing-library/react'

test('works', () => {
    setup()

    screen.debug()
})

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.

import {logDOM} from '@testing-library/react'

logDOM() // logs out document.body

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions