You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw the original issue which resulted in the addition of the userEvent.hover() function. We make frequent use of this userEvent in our codebase and are quite happy with how it works, so thank you for adding it! :-)
We have certain DOM elements which, after the user hovers over them for N # of ms, show a tooltip. We'd like to test both the happy path (i.e. the tooltip shows up when the user hovers for the prescribed # of ms) and the alternate path (ie no tooltip appears when the user hovers for less than the # of ms). The cleanest way I could think of to do this was via something like:
The specific name timeDuration is just contrived to illustrate the example. However, after parsing the code for the hover action, there doesn't appear to be any API equivalent to the above.
The text was updated successfully, but these errors were encountered:
'unable to hover element as it has or inherits pointer-events set to "none".',
)
}
returnthis.pointer({target: element})
}
There is no magic and no intention to add any. If you want to wait for a specific duration just do so outside of the hover action:
awaituserEvent.hover(element)awaitnewPromise(r=>setTimeout(r,500))// wait for (at least) 500msexpect(screen.queryByText('Tooltip Text')).not.toBeInTheDocument()awaitnewPromise(r=>setTimeout(r,200))// wait another (at least) 200msexpect(screen.getByText('Tooltip Text')).toBeInTheDocument()
(Note that waiting for something to not have happened might be brittle if the waited duration is too close to the actual threshold as the asynchronous approach per specs gives up control over the order of execution even though it might be predictable.)
Problem description:
I saw the original issue which resulted in the addition of the
userEvent.hover()
function. We make frequent use of this userEvent in our codebase and are quite happy with how it works, so thank you for adding it! :-)We have certain DOM elements which, after the user hovers over them for N # of ms, show a tooltip. We'd like to test both the happy path (i.e. the tooltip shows up when the user hovers for the prescribed # of ms) and the alternate path (ie no tooltip appears when the user hovers for less than the # of ms). The cleanest way I could think of to do this was via something like:
The specific name
timeDuration
is just contrived to illustrate the example. However, after parsing the code for the hover action, there doesn't appear to be any API equivalent to the above.The text was updated successfully, but these errors were encountered: