From 8c29d1964abfe84e5242bac4cfdde52085924c5a Mon Sep 17 00:00:00 2001 From: Sam Magura Date: Sun, 12 Sep 2021 10:33:30 -0400 Subject: [PATCH] add testing example to README --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 288dac4..933eddb 100644 --- a/README.md +++ b/README.md @@ -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( + + Hover over me! + , + ); + + 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: