Skip to content

Instantly share code, notes, and snippets.

@aautar
Created November 28, 2018 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aautar/d331d742fd07dc4de4f52f5af9439673 to your computer and use it in GitHub Desktop.
Save aautar/d331d742fd07dc4de4f52f5af9439673 to your computer and use it in GitHub Desktop.
Simulate DOM event within a Jest test
// From https://github.com/facebook/react/issues/3249#issuecomment-177750141
var event = document.createEvent("HTMLEvents");
event.initEvent("click", true, true);
var target = $('.about-page-link')[0];
target.dispatchEvent(event);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment