emberjs / emberjs/ember-test-helpers

Test not waiting promises

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

Description

### Problem

The test is not waiting the promise to return the data.
Ember version: 3.4

### Test scenario

I'm using `triggerKeyEvent` to trigger an action at a text input:
```js
await fillIn('[data-test-search-input]', 'Test');
await triggerKeyEvent('[data-test-search-input]', 'keydown', 13);
await settled();
```
The action goes on a server and gets some data:
```js
actions: {
onTriggerKey() {
return this.getDataFromServer().then(data => set(this, 'data', data));
}
}
```
But i'm facing some strange behaviours. Sometimes the `await settled()` wait the promise return the data and sometimes not. This is very hard to reproduce because the test pass in the most of the times.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.