Enzyme tests failing with UncontrolledTooltip
See original GitHub issueIssue description
- components:
UncontrolledTooltip
- reactstrap version
5.0.0-alpha.4
- import method
es
- react version
16.2.0
What is happening?
Enzyme tests are failing when UncontrolledTooltips are used, but the render is working completely fine as expected
What should be happening?
Enzyme tests should pass
Error message in console
The target 'UncontrolledTooltipExample' could not be identified in the dom, tip: check spelling
at getTarget (node_modules/reactstrap/dist/reactstrap.cjs.js:135:13)
at Tooltip.componentDidMount (node_modules/reactstrap/dist/reactstrap.cjs.js:4062:22)
at commitLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:8770:24)
at commitAllLifeCycles (node_modules/react-dom/cjs/react-dom.development.js:9946:9)
at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:542:14)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:219:27)
at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:126:9)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:36:27)
at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:61:35)
at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:581:16)
at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:438:27)
at commitRoot (node_modules/react-dom/cjs/react-dom.development.js:10050:9)
at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:11017:42)
at performWork (node_modules/react-dom/cjs/react-dom.development.js:10967:7)
at requestWork (node_modules/react-dom/cjs/react-dom.development.js:10878:7)
at scheduleWorkImpl (node_modules/react-dom/cjs/react-dom.development.js:10732:11)
at scheduleWork (node_modules/react-dom/cjs/react-dom.development.js:10689:12)
at scheduleTopLevelUpdate (node_modules/react-dom/cjs/react-dom.development.js:11193:5)
at Object.updateContainer (node_modules/react-dom/cjs/react-dom.development.js:11231:7)
at node_modules/react-dom/cjs/react-dom.development.js:15226:19
at Object.unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:11102:12)
at renderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:15225:17)
at Object.render (node_modules/react-dom/cjs/react-dom.development.js:15290:12)
at Object.render (node_modules/enzyme-adapter-react-16/build/ReactSixteenAdapter.js:220:50)
at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:98:16)
at mount (node_modules/enzyme/build/mount.js:19:10)
at Object.<anonymous>.it (src/App.test.js:13:21)
at new Promise (<anonymous>)
at Promise.resolve.then.el (node_modules/p-map/index.js:46:16)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:160:7)
✕ renders without crashing (6ms)
Code
Here’s a brand new create-react-app application demonstrating this issue https://github.com/karthikiyengar/reactstrap-error
npm run test
to run Enzyme
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
reactjs - How to create an unit test for UncontrolledTooltip from ...
If I want to implement an unit test (e.g. jest + enzyme ) for testing its state as either open or close, how...
Read more >Top 5 enzyme-adapter-react-16 Code Examples - Snyk
How to use enzyme-adapter-react-16 - 10 common examples. To help you get started, we've selected a few enzyme-adapter-react-16 examples, based on popular ...
Read more >[Solved]-Testing specific MaterialUI Icon-Reactjs
Was able to test this by rendering the Material UI icon, grabbing the inner html, then comparing it to my components icon.
Read more >React Unit Testing with Enzyme and Jest Part 2 (P5D52)
Project 5 Day 52: Today we will write some unit tests for our React components using Enzyme and Jest.See a professional front-end developer ......
Read more >Jest Test with Enzyme and Shallow - YouTube
It covers Test Driven Development (TDD) basics with Jest and Enzyme. A major theme is how to focus on one component at a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Many thanks!
This does the trick 😃
@karthikiyengar , ur answer works for only one tooltip, If there are dynamic Uncontrolled tooltips (data is dynamic) , my page is crashing during the test