Add option to set a class on target element on hover. Useful for testing hover states either by manually adding .my-hover-class on top of :hover in CSS or with a plugin such as the one for PostCSS or Storybook.
Why:
Allow testing of CSS hover states using userEvent.hover / userEvent.unhover or other commands that move the mouse.
How:
Add a new config option hoverClass (string) which defaults to null. When set (non-null), target.classList.add(hoverClass) is called whenever mouseenter is emitted and target.classList.remove(hoverClass) whenever mouseleave is emitted.
What:
Add option to set a class on target element on hover. Useful for testing hover states either by manually adding
.my-hover-class
on top of:hover
in CSS or with a plugin such as the one for PostCSS or Storybook.Why:
Allow testing of CSS hover states using
userEvent.hover
/userEvent.unhover
or other commands that move the mouse.How:
Add a new config option
hoverClass
(string) which defaults to null. When set (non-null),target.classList.add(hoverClass)
is called whenevermouseenter
is emitted andtarget.classList.remove(hoverClass)
whenevermouseleave
is emitted.Checklist: