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.

Custom events by ember-gestures are not working in testing using ember-test-helpers

See original GitHub issue

I am writing a ember component ember-slider. I wrote some basic test cases for the component. But when I tried to write a test case triggering ‘tap’ event using ember-test-helpers, the event was not recognised by “ember-gestures” add-on which I am using capture user actions like tap and pan.

Following is the code I am using to test the tap functionality. Please help me figure out what is going wrong. I am not sure if I have provided enough detail here. Please let me know in case if more required.

test('tap to change value', async function(assert) {
     assert.expect(2);
     await render(hbs`{{ember-slider initialValue=10}}`);
     assert.equal(parseInt(this.$('.slider-value')[0].textContent), 10, 'Value set to 10');
    
     // The following jQuery event callback is called after tap('.ember-slider'); gets executed. But the tap event inside my component is not.
     this.$('.ember-slider').on('click', function(e) {
       console.log("Entered ", e);
     });
     
     await tap('.ember-slider');
     assert.equal(parseInt(this.$('.slider-value')[0].textContent), 0, 'Value set back to 0 by tapping');
});

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
rwjbluecommented, Aug 2, 2018

OK, @rondale-sc and I spent some time poking at this this morning. Somewhat random brain dump follows…

  • We created a repo to show the failure (mostly following from my last comment) here.
  • Hammer.js uses fallback logic to determine which events to hook into and use for firing the tap event. That fallback logic is here.
  • The tests in that repo pass on Safari (does not support PointerEvent) but not on Chrome (supports PointerEvent).
  • The internal fireEvent helper function is not aware of PointerEvents, and for touchstart / touchend events we fire the generic Event.

Action items:

  • Add support for touch events to the fire event helper
    • Use PointerEvent when window.PointerEvent is present and fallback otherwise
  • Add Hammer.js as a dev dependency to this repo (either via ember-gestures, or just as an app.import) along with a smoke test like the one written in the demo repo above to confirm tap continues to work with Hammer.js.
0reactions
RVenkateshcommented, Aug 2, 2018

@eriktrom I checked it with 1.0.0 version. The issue is still there. May be it is related to what @rwjblue mentioned.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ember test with async await functions not working as intended
I am using ember-simple-auth with custom authenticator, which is pretty basic. Just sends login request to backend API, catching error when ...
Read more >
ember-gestures - Bountysource
I'm using Ember-Cordova to build to Android and have noticed that on Android the panEnd event does not fire consistently. On iPhone it...
Read more >
In an integration test, using the test helper `triggerKeyEvent ...
I was able to trigger it by using the native event dispatcher: const submitForm = async (element) => { const submitEvent = new ......
Read more >
Awesome Ember.js
js data layer built with Orbit.js. ember-data-storefront - A collection of APIs that address common data-loading issues. ember-m3 - This addon provides an ......
Read more >
@ember/test-helpers - npm
Helpers for testing Ember.js applications. Latest version: 2.9.3, last published: 3 days ago. Start using @ember/test-helpers in your ...
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