Skip to content

Instantly share code, notes, and snippets.

@paigen11
Created March 28, 2020 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paigen11/9e5bb432477d5ff090c723c8bec7a165 to your computer and use it in GitHub Desktop.
Save paigen11/9e5bb432477d5ff090c723c8bec7a165 to your computer and use it in GitHub Desktop.
Example of using previousSibling or nextSibling to target elements around a particular element in React Testing Library.
const keyToSelect = await component.findByText('key to select');
userEvent.click(keyToSelect.previousSibling.firstChild.firstChild);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment