Search code examples
ember.jsember-cli

Can't get simple acceptance test to function properly


the visit will happen fine and I see the live application page in the bottom right corner but then the equal assertion never happens and basically the test is always "running" and no assertions ever get made, any guidance would be greatly appreciated, I am on ember-cli 0.1.11 and ember 1.9.1, I am testing by going localhost:4200/provider/tests where my baseUrl is set to '/provider/'

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

var application;

module('Acceptance: Login', {
setup: function() {
  application = startApp();
},
teardown: function() {
  Ember.run(application, 'destroy');
}
});

test('visiting /login', function() {
 visit('/login');

andThen(function() {
 equal(currentPath(), 'login');
});
});

my startApp looks like this

 import Ember from 'ember';
 import registerAcceptanceTestHelpers from './201-created/register-acceptance-test-helpers';
 import Application from '../../app';
 import config from '../../config/environment';
 import 'simple-auth-testing/test-helpers';

 export default function startApp(attrs) {
   var application;

   var attributes = Ember.merge({}, config.APP);
    attributes = Ember.merge(attributes, attrs); // use defaults, but you can  override;

  Ember.run(function() {
      application = Application.create(attributes);
      application.setupForTesting();
      registerAcceptanceTestHelpers();
     application.injectTestHelpers();
  });

  return application;
}

Solution

  • Okay so i figured out the issue is related to

    "We have several scheduled timers running in the app via run.later

    When a test action (e.g. click) gets beyond the login in our application, the timers start and all subsequent thennables are blocked."

    "The problem this causes is that wait used by Ember.Testing waits until all timers have been executed before moving on. Which will never happen in most of my routes due to this polling timer."

    mentioned here and here

    https://github.com/emberjs/ember.js/issues/3008#issuecomment-73246784

    http://discuss.emberjs.com/t/proper-way-to-handler-timers-w-ember-testing/4693

    hope this helps people