How to test a style with :hover using jasmine

1,002 views
Skip to first unread message

Mukund Katpatal

unread,
Jun 7, 2019, 1:58:17 PM6/7/19
to Jasmine
I have a style on my table row. And I dont have any events specified in my templates. All I have is below style in my css which I want to test. If you hover on a row, I want to test that the color becomes red. I tried dispatchEvent as well as triggerEventHandler. Nothing worked. Any pointers?

tbody tr {
&:hover {
background-color: red;
cursor: pointer;

Gregg Van Hove

unread,
Jun 7, 2019, 2:22:41 PM6/7/19
to jasmi...@googlegroups.com
I'm not sure this is something you'll be able to test with just JavaScript. You might be able to do something with Selenium/WebDriver, but even then checking for the current background color in a test like that seems like more effort than the test is really worth. The problem is that this interaction is handled entirely by the browser without any JavaScript code at all. You would have to actually move the mouse over the element with the `:hover` pseudo-selector attached in order to get the browser to make the change.

Hope this helps. Thanks for using Jasmine!

-Gregg

--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at https://groups.google.com/group/jasmine-js.
To view this discussion on the web visit https://groups.google.com/d/msgid/jasmine-js/a814b968-a7f7-46f4-afe0-851c95aeecf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mukund Katpatal

unread,
Jun 8, 2019, 4:40:02 PM6/8/19
to jasmi...@googlegroups.com
Thank you. It helped 


For more options, visit https://groups.google.com/d/optout.
--
Thanks and Regards
Mukund
---------------------------------------------------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages