It says that because tooltip is not a d3 selection, but rather it is natively selected using getElementById.
You can either make your tooptip selection to d3 selection by using d3.select('#tooltip') Or you can keep your native element and use native tooltip.setAttribute function to set the attribute.
That said, your test will still not pass. You’re using d3 v6 but using the mouseover API of d3 v5.
You’ll need to either switch back to d3 v5 OR if you prefer to use d3 v6, look at the migration guide:
Thanks for the info.
I’m trying to figured out the right solution from your suggestion. I prefer to still stick with d3 v6 but we’ll see which one is work.