-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationpinnedPinned for different reasons. Issues with this label won't be flagged as stale by stalebotPinned for different reasons. Issues with this label won't be flagged as stale by stalebot
Description
import { render, getByText } from '@testing-library/react';
import React from 'react';
render(<div>some text</div>);
getByText(document.body, 'some text');
=> testing-library/prefer-screen-queries: Avoid destructuring queries from render result, use screen.getByTestId instead
In this case, we use the function imported from @testing-library/dom
reexported from @testing-library/react
that allows to search for an element in the tree of any other element (like within
). This exact example is of course useless (we can use screen
) but this is to show the problem with a simple testcase. I believe this is a valid use case and shouldn't be flagged by testing-library/prefer-screen-queries
.
What do you think?
Semigradsky
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationpinnedPinned for different reasons. Issues with this label won't be flagged as stale by stalebotPinned for different reasons. Issues with this label won't be flagged as stale by stalebot