1
votes

I have a very basic Ember-CLI application running with about 75 or so QUnit assertions that all pass. When I generate an acceptance test:

ember generate acceptance-test games

Which produces:

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

var application;

module('Acceptance: Games', {
  beforeEach: function() {
    application = startApp();
  },

  afterEach: function() {
    Ember.run(application, 'destroy');
  }
});

test('visiting /games', function(assert) {
  visit('/games');

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

My tests then begin break on a JSHint unit test for the route:

52. JSHint - unit/routes/games: global failure (1, 0, 1)
1. Uncaught Error: Assertion Failed: calling set on destroyed object
Source: http://localhost:4200/assets/vendor.js:14407

I'm just starting with these Ember-CLI Integration tests, so perhaps there's something I'm missing? The error seems like that maybe I'm setting up something but not tearing it down properly somewhere else? Even if that's the case, I'm not sure why adding one acceptance test would produce this while without the test everything passes.

The console also shows:

WARNING: Library "App" is already registered with Ember.
ember.debug.js:3940 Uncaught Error: Assertion Failed: calling set on destroyed object

For reference, I'm on:

DEBUG: Ember      : 1.10.0
DEBUG: Ember Data : 1.0.0-beta.15
DEBUG: jQuery     : 1.11.2

Thanks in advance,

Update:

When removing the generated code from the acceptance test and replacing with something like:

assert.ok(true);

All of the tests pass. As soon as I add something like:

visit('/games');

I then start seeing the "calling set on a destroyed object" error seemingly randomly on various unit tests.

1
Does that new test pass if you run only it?steveax
@steveax this acceptance test always passes regardless of by itself or with all of the unit tests. The issue is that when the acceptance test exists as part of the suite, there's this JSHint error that gets introduced, which seems to be on the "games.index" route where I'm "calling set on destroyed object". My games.index is pretty straight forward in that it's only implementing the model hook - model: function () { return this.store.find('game'); }Jon

1 Answers

1
votes

I finally tracked this down. The issue was with an initializer that essentially creates a running clock (something like this) that I use for redrawing of views by over time.

My initializer was using setTimeout which updates properties of the initializer. Given the error message, I'm assuming the initializer was living longer than a given test and was calling setProperties after being destroyed.

For the time being, I wrapped my timer with:

if (!this.get('isDestroyed') && !this.get('isDestroying')) {
...
}

Just to get tests passing, but it seems as if I should get rid of setTimeout all together in favor of Ember.run.later?