How to test code that uses `run.later`



I am trying to setup an integration test here but I don’t manage to use triggerEvent before the run.later from this method.

I tried to play around with the run loop but didn’t find how to handle this correctly. I had thought at first that with the running loop being manually managed in the tests calling triggerEvent right after visit would propagate the event directly and that calling andThen after would let the promises complete and make my test pass :slight_smile:

btw: the feature I’m trying to implement seems to be working in the dummy application.


remove run laters and replace them with this, annoying but a working solution at the moment.

setTimeout(, function() { 
           console.log("hello"); }), 1000);


@leojpod I think what’s missing is a helper that allows you to control how messages are destroyed. ember-simple-auth has something similar for authentication sessions in acceptance test. You can see how it works here

What you might need is a helper that would pause destroying of a flash object until you tell it to. Something like pauseFlashMessages() and continueFlashMessages(). You’d need to try it out and see what feels more natural.

It would make a good extension, in the same way that simple-auth provides and extension for testing called simple-auth-testing


It somehow work but not quite :smile: The results then depends on my the timer delay.


@tarasm then I should probably reopen the flash object class to change the how the destroyTimer is handled.
It might not be as simple as using pause/continueFlashMessages() though because what the flash object does when it’s component get mouseovered (on mouseenter) is to cancel the timeout. So I cannot just pause, trigger and then continue else it will kill the timer twice (well why not?) and then put it back (which I need to avoid if it’s mouseovered. Reopening the flash object class and setting a property to true/false instead of setting/removing the timer should be fine in coordination with the pause/continueFlashMessages()

Thanks to both of you for your help! It’s nice to see that the community is so alive.