question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can't test customEvents

See original GitHub issue

We have these on our Application:

customEvents: {
    webkitAnimationEnd: 'animationEnd',
    msAnimationEnd: 'animationEnd',
    oAnimationEnd: 'animationEnd',
    animationend: 'animationEnd'
}

…and in a component integration test:

this.render('{{foo-bar}}')
this.$().trigger('click') // works
this.$().trigger('animationEnd') // doesn't work

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
mitchlloydcommented, May 26, 2016

Got some help from @rwjblue on this one today and wanted to share here:

It seems that a nicer (but currently undocumented solution) is to extend the EventDispatcher:

// inside of app/event_dispatcher.js
import Ember from 'ember';

export default Ember.EventDispatcher.extend({
  init() {
    this._super(...arguments);
    this.events.webkitAnimationEnd = 'animationEnd'
  }
});

This works and feels like a better solution since setting up custom events is unlikely to change based on the current environment.

The _ in the file name is surprising but currently needed. Also there could be a more intentional hook to let users edit the events.

0reactions
rwjbluecommented, May 26, 2016

Thanks for writing up the solution here. I think I’m going to close this issue now that the solution is documented, but I suspect we might still want to do some work in Ember to make this a bit more ergonomic. I’m happy to help someone spearhead an RFC on this, if they are interested in it…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Test Events Tool Issues in Meta Events Manager
Check out these tips to troubleshoot problems you may encounter while using the Test Events tool in Meta Events Manager.
Read more >
TypeScript doesn't allow event : CustomEvent in ... - GitHub
In my TypeScript project, I'm trying to write the following code: buttonEl.addEventListener( 'myCustomEvent', ( event : CustomEvent ) => { //do ...
Read more >
How to test a method dispatching custom event - Stack Overflow
It's a little clunky looking, but something like this should work if you want to verify an event with the expected type was...
Read more >
React, Jest, and CustomEvent testing - libertyseeds.ca
React, Jest, and CustomEvent testing. Simple problem: I need my React component to communicate an event to a JQuery plugin in Rails.
Read more >
Dispatching custom events - The Modern JavaScript Tutorial
For automated testing, to “click the button” in the script and see if the interface reacts correctly. Custom events with our own names...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found