Uncaught Error: Assertion Failed: calling set on destroyed object

ember-cliember.jsqunit

working in ember-cli testing. After all tests passed it returns extra two test with errors.

Uncaught Error: Assertion Failed: calling set on destroyed object
Source : '../dist/assets/vendor.js:13269'

this is one unit test configuration

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

var App;

module('An Integration test',{
    setup:function(){
        App=startApp();
    },
    teardown: function() {
        Ember.run(App, 'destroy');
    }
});

Best Solution

This is either because in the result of a promise or any other deferred code you do not check the destroy status of an object, or because you didn't teardown something that has been setup and interact with DOM events or anything external to the core of Ember.

I used to have this especially on some jQuery plugins which I mapped to Ember, and during the tests the plugins were destroying too slowly and I was then either not using a run loop, or not checking the destroyed status of the Ember object I was manipulating.

You can do so with:

if ( !(obj.get('isDestroyed') || obj.get('isDestroying')) ) {
  // do your destroying code setting stuff
}

Also think about destroying any jQuery plugins that might have been initialised in the code of your views (anything setup in didInsertElement should be teardown in willDestroyElement for example).

Related Question