dom-testing-library icon indicating copy to clipboard operation
dom-testing-library copied to clipboard

logRoles doesn't support RenderResult

Open amaschas opened this issue 1 year ago • 0 comments

  • @testing-library/dom version: 8.17.1
  • Testing Framework and version: jest 26.6.0
  • DOM Environment: jest-environment-jsdom 26.6.2

Relevant code or config:

test("A sample test.", () => {
    const component = render(() => (<div>Testing</div>));
    logRoles(component);
});

What you did:

I'm trying to log the roles available in a rendered component.

What happened:

I get an error telling me that logRoles only works with HTMLElement and not RenderResult.

Problem description:

I'm not really sure how logRoles is even supposed to be used, given that it can't show me the roles available in a RenderResult. It's actually easier to just to screen.getByRole('foo') at this point to find out what roles are available within your component. I think that logRoles should either just take a RenderResult, or the documentation should explain how to use logRoles with a RenderResult, since most users are probably just going to render their test component, and then want to see what roles they can test for.

amaschas avatar Sep 09 '22 18:09 amaschas