React-tooltip: Package breaks react testing library out of the box: Invalid insertion of STYLE node

Created on 12 Mar 2021  路  5Comments  路  Source: wwayne/react-tooltip

In tooltip/src/index.js, on lines 202 - 208:
```javascript
if (!domRoot.querySelector('style[data-react-tooltip]')) {
const style = document.createElement('style');
style.textContent = baseCss;
style.setAttribute('data-react-tooltip', 'true');

  domRoot.appendChild(style);
}

```

When running any basic test using React Testing library on a page that has a Tooltip element, this produces the error: HierarchyRequestError: Invalid insertion of STYLE node in #document node.

I've tried manually adding the baseCss, manually adding style tag, and/or manually adding an attribute on the tooltip itself or its targeted JSX tag with style={{'data-react-tooltip':true}}, to no avail. Commenting out these lines in the package allows the testing suite to run fine, but I'm not sure how to arrange my code so that the querySelector returns a tag and avoids this code block inserting an invalid style node.

Most helpful comment

+1 , I can confirm the same issue - reverting back to 4.2.8 fixed my issue.

All 5 comments

Also having this problem while trying to update from Version 3.11.6 to 4.2.16 tests that were previously passing are now all failing with this error.

+1 , I can confirm the same issue - reverting back to 4.2.8 fixed my issue.

The 4.2.17 fixed this issue on my tests

+1 for 4.2.17

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kristinadarroch picture kristinadarroch  路  3Comments

abijames picture abijames  路  3Comments

Ericky14 picture Ericky14  路  3Comments

tonynd picture tonynd  路  3Comments

rothwelljeff picture rothwelljeff  路  3Comments