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.

Not waiting for router transitions

See original GitHub issue

Problem

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 awaits click() and fails: https://github.com/simonihmig/async-model-reproduction/blob/master/tests/acceptance/foo-test.js

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
rwjbluecommented, Jan 26, 2019
3reactions
simonihmigcommented, Sep 12, 2018

@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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-router not waiting for animation before changing route
The animation has been applied on Hello route when it leaves. Actually, the transition is set up such that when the Hello page...
Read more >
Vue Router with Out In transition not waiting for component to ...
Hi, all. I've got a code base that's working as intended except for one thing: The vue router with a transition doesn't seem...
Read more >
Transition Hooks - UI-Router
This guide describes UI-Router Transition Hooks, which allow a developer to tap into the lifecycle events of a Transition. Be sure you've ...
Read more >
Animating Vue Router Transitions in Vue 3 - YouTube
Vue Router transitions are a quick and easy way to add some flair to Vue app. They allow you to add smooth animations/...
Read more >
Page Transitions In React
It will wait for the existing component to finish its animation before the new component is rendered. ... Component not unmounting on route...
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