Not waiting for router transitions
See original GitHub issueProblem
settled()
and all other async test helpers that use it do not wait for a model hook implemented using native async/await.
Test scenario:
In an application test there is an await click()
, which triggers a route transition. The model hook is implemented using native async/await. The test continues to run beyond the await, even before the model hook has resolved (which means the new route hasn’t rendered yet, though the test expects that)
Solution
As suggested by @rwjblue on Discord: wait for active router transitions, as is the case in old ember-testing
: https://github.com/emberjs/ember.js/blob/615daa2eeef971e578de75e6319baca3b0ec0508/packages/ember-testing/lib/helpers/wait.js#L45-L49
Reproduction
https://github.com/simonihmig/async-model-reproduction
First test uses an explicit delay and passes. Second just await
s click()
and fails: https://github.com/simonihmig/async-model-reproduction/blob/master/tests/acceptance/foo-test.js
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:8 (7 by maintainers)
Top GitHub Comments
Fixed in https://github.com/emberjs/ember-test-helpers/pull/482, released in @ember/test-helpers@1.2.1.
@rwjblue getting totally confused now. I just pushed another commit to the repo, with a bar route that returns an RSVP promise. And even that is not working!? So seems not even related to native Promises/async!??
I mean this has always been working, I am getting totally lost now… 🤔
Anything that has changed, that would explain this?