2
votes

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;
}
3
Did you solve it? I'm running into same issue.Daniel Kmak

3 Answers

2
votes

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

1
votes

Background


I ran into same issue but when I was using ember-cli-coffeescript. I coulnd't run even simple integrated test. My app was generated using old ember cli and then I updated cli versions, but it seems that I had deprecated test blueprints generation. I ran ember new, installed ember-cli-coffeescript and generated simple acceptance-test. I noticed that there were some differences and you can't return application in your module.setup.

Solution


setup
module 'Acceptance: Login',
  setup: ->
    application = startApp()
    ###
    Don't return as Ember.Application.then is deprecated.
    Newer version of QUnit uses the return value's .then
    function to wait for promises if it exists.
    ###
    return

It is generated on the fly with correct hooks, etc. but you have to reinstall ember-cli-coffeescript addon, if you used older version before:

ember install:addon ember-cli-coffeescript

I hope that solves someone frustration and time.

0
votes

what's the name of your test file? The convention is to have -test postfix in the file name.

If you don't have it, then your file won't be recognized as test file. In your case it could be login-test.js.

Does this help?