Unit testiing visit(route) with ongoing Timer never end

I have the following simple test for testing a route:

`import Ember from 'ember'`
`import startApp from '../helpers/start-app'`

App = null
module 'Acceptance: index',
  setup: ->
    App = startApp()

  teardown: ->
    Ember.run App, 'destroy'

test 'visiting /index', ->
  visit '/index'
  andThen ->
    equal currentPath(), 'index'

However, I have a component on that page with schedule timer:

`import Ember from 'ember'`
CurrentTime = Ember.Component.extend
    current_time: new Date()
    timer_id : null
    tagName: 'span'
    tick: ->
            @set 'current_time', new Date()
            @timer_id = Ember.run.later this, @tick,1000
            return

    _addTimer:  Ember.on 'didInsertElement',  ->
       @timer_id = Ember.run.later this, @tick,1000
    _deleteTimer: Ember.on 'willDestroyElement' , ->
        Ember.run.cancel(@timer_id)


`export default CurrentTime`

This made the test case never end since ember-testing check if there is any schedule timer left. How should I test the page?

Here are a couple options (might be more):

  • Do not have the timer enabled when Ember.testing === true
  • use setTimeout instead of Ember.run.later