Unit test on component is not working when it has mixin


#1

I am trying to test my component with unit test to see if every computed property works.

Here is my component date-navigation-bar with a mixin called time-nav

import Ember from 'ember';
import layout from '../templates/components/date-navigation-bar';
import TimeNav from '../mixins/time-nav';

export default Ember.Component.extend(TimeNav, {
})

Ember test just fails me by giving me this assertion:

You have turned on testing mode, which disabled the run-loop's autorun. 
You will need to wrap any code with asynchronous side-effects in a run.

I don’t know why is this happening, but by stopping import the time-nav the assertion goes away. However my tests fail because the component could not work probably.

Does anyone having the same problem as me? I think the is a common issue.


#2

Wow I have figured it out right after I posted.

In my mixin, this one thing is causing the problem:

 onKeyChange: Ember.on('init', Ember.observer('something', function () {
    Ember.run.once(this, 'processKeyChange');
  })),

I removed the on('init') part and everything works fine. But what should I do if I want to keep the on('init') and make my tests pass?