[Vuejs]-How to test that a Vue directives is called on hover/mouseover?

1👍

UPDATED

From comments below:

expect(buttonWrapper.attributes('aria-describedby')).toBeDefined()
const adb = buttonWrapper.attributes('aria-describedby')

const tip = document.querySelector(`#${adb}`)
expect(tip).not.toBe(null)
expect(tip.classList.contains('tooltip')).toBe(true)

OLD

Try to test it by checking html content, e.g.:

buttonWrapper.trigger('mouseover');
expect(wrapper.contains("someText')).toEqual(true);

https://vue-test-utils.vuejs.org/api/wrapper/contains.html

Or maybe (not sure):

expect(wrapper.find("BTooltip').isVisible()).toEqual(true);

Do not forget to remove any mocks, e.g.:

directives: { 'b-tooltip': BTooltipDirective }

Leave a comment