emberjs / emberjs/ember-test-helpers

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

Open
#402 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
188
Forks
254
PR merge metrics
No merged PRs in 30d

Description

I am writing a ember component [ember-slider](https://github.com/RVenkatesh/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');
});

Contributor guide

Open the contributing guide

Research direction

Reproduce the “tap to change value” test from the issue in ember-slider using ember-test-helpers and ember-gestures. Start by comparing the tap helper’s generated event with the event ember-gestures handles, then verify the component’s tap callback is reached and the value assertion changes from 10 to 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.