Skip to content

How to test custom events? #424

Answered by egil
majorimi asked this question in Q&A
Jun 10, 2021 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi @majorimi,

I've taken the liberty of converting this issue to a Q/A discussion instead.

This is related to the issue #341, but this should actually be possible with the current release of bUnit.

bUnit has a method, TriggerEventAsync, that you can use to trigger any custom event bound attached to the DOM, and the error message you quote from bUnit highlights that the two custom events you have in your component library is indeed available for invocation (onmouseenter, onmouseleave).

What you need to do is this:

await cut.Find("element-with-custom-events").TriggerEventAsync("onmouseenter", new MouseEventArgs());
await cut.Find("element-with-custom-events").TriggerEventAsync("onmouseleave", 

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@majorimi
Comment options

@egil
Comment options

egil Jun 11, 2021
Maintainer

Answer selected by majorimi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #423 on June 10, 2021 21:01.