Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.

add testing example to README #331

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,25 @@ function App() {

[Read more about plugins here](https://atomiks.github.io/tippyjs/v6/plugins/).

## 🧪 Testing with `@testing-library/react`

```jsx
it('shows a tooltip', () => {
render(
<Tippy content="myTooltip">
<span data-testid="referenceElement">Hover over me!</span>
</Tippy>,
);

const referenceElement = screen.getByTestId('referenceElement');
fireEvent.mouseEnter(referenceElement);

expect(document.querySelector('.tippy-content')).toHaveTextContent(
'myTooltip',
);
});
```

## 🌈 Multiple tippies on a single element

You can nest the components like so:
Expand Down