Weird behaviour in test runner after update to 1.10 + 0.1.15 combo

I’ve updated my project to Ember 1.10 and CLi to 0.1.15 and my tests suddenly blurped.

Actually, my tests pass, but sometimes second after they pass, they immediately fail due to following reason:

Uncaught Error: Called stop() outside of a test context@ 1 ms
Source: 	
http://localhost:4200/assets/test-support.js:2601

I also have another problem, every next acceptance test floods console with warnings:

WARNING: Library "Misago" is already registered with Ember.

I’ve looked under the hood and found repeated calls to “App Version” initalizer being culprit. Perhaps new test runner skips certain libs during cleanup?

Just found this with:

"ember-cli": "0.1.15",
"ember": "1.11.0-beta.1",
"ember-data": "1.0.0-beta.15",

I’m seeing the exact same issue with ember-cli 0.1.15 and ember 1.10.0 with ember-data 1.0.0-beta.12.

I’d be happy to take a look at a small demo repo showing the issue. There were a few changes in 0.1.15 (specifically the update to ember-cli-qunit) that made tests starting async, and could be related.

The one test that this is happening in for me is rather long. I’m not sure what I can do to reproduce this.

Don’t have demo but my project is open source and hosted on github.

I’m fairly certain this is due to a test that tests behavior that returns synchronously but is in fact still resolving a promise. andThen moves on, but the application code is still at work.

I’ve took break for some time to actually write features instead feeding my frustration, but I would like to write tests for my code.

I’ve been sitting on this for 6 hours now, and I am calling it quits, I just can’t get my acceptance tests to work:

import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from '../helpers/start-app';

var application;

module('Acceptance: Application Error Handler', {
  beforeEach: function() {
    application = startApp();
  },
  afterEach: function() {
    Ember.run(application, 'destroy');
    Ember.$.mockjax.clear();
  }
});

test('some unhandled error occured', 1, function(assert) {
  Ember.$.mockjax({
    url: "/api/legal-pages/privacy-policy/",
    status: 500,
    responseText: {
      'detail': 'Some terrible Django error'
    }
  });

  visit('/privacy-policy');

  andThen(function() {
    assert.equal(currentPath(), 'error');
  });
});

This is first test in my suite, but andThen never gets fired, so my suite stucks forever waiting for this one test to complete:

Maybe Ember-CLI 0.2.0 will solve this, but as it is now I am too tired and frustrated to continue looking for source of issue. Maybe its something about Brocfile?

I know that if I comment out storeConfigInMeta: false, my andThen’s get called, but test runner seizures itself with following error:

Assertion Failed: Unable to add "ember-application" class to rootElement. Make sure you set rootElement to the body or an element in the body.

Somebody please tell me what I am doing wrong. I’ve posted linky to my ember app few posts ealier.

seems like you may have lose Ember.run.later laying around or are not wrapping your ajax call’s in an ember.run compliant way, that is a typical issue with andThen’s not running, the place to debug would be in the wait function https://github.com/emberjs/ember.js/blob/master/packages/ember-testing/lib/helpers.js#L201

other things mentioned where andThen’s won’t run properly, the Misago library also might be the underlying problem in some way

1 Like

Woah, I was using this cookbook recipie myself. Added condition for clock to don’t tick in tests and tests are working again!

Testrunner still floods my console with warnings, but I can resume writing tests.

For the record:

Seems like warnings flood was bug in Ember-CLI-App-Version:

https://github.com/embersherpa/ember-cli-app-version/pull/14

Did you ever find a solution for this? I’m fairly certain that I have the same issue after upgrading to 0.1.15 and 0.1.16.