Skip to content
Discussion options

You must be logged in to vote

element.click() fires one click event. user.click() is a pointer interaction: hover (unless skipHover), then pointerdown/mousedown, focus, pointerup/mouseup, then click.

Native click skips two checks that matter for the disabled-button case:

  1. pointer-events: none throws (assertPointerEvents).
  2. Disabled form controls skip mouseup and click (isDisabled in the mouse up path). The handler is not called.

jsdom's HTMLElement.click() often still dispatches click on a disabled button. A real user cannot do that, and user.click() will not fire the callback.

Use user.click() for those tests. Keep element.click() only when you want a single synthetic click with no pointer checks.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@snowystinger
Comment options

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