未捕获错误:断言失败:在已销毁对象上调用set [英] Uncaught Error: Assertion Failed: calling set on destroyed object
问题描述
未捕获错误:断言失败:对已销毁对象调用set
源:'../ dist / assets / vendor.js:13269'
这是一个单元测试配置
从ember导入Ember;
import {test,moduleFor} from'ember-qunit';
从'../helpers/start-app'导入startApp;
var App;
模块('一个集成测试',{
设置:function(){
App = startApp();
},
teardown:function (){
Ember.run(App,'destroy');
}
});
这是因为在承诺或任何其他延迟代码,您不检查对象的销毁状态,或者因为您没有拆卸已经设置并与DOM事件或Ember核心外部任何内容交互的内容。
我以前特别在一些我映射到Ember的jQuery插件上,而在测试期间,插件正在摧毁太慢,我不是使用运行循环,还是不检查被破坏的状态我正在操纵Ember对象。
你可以这样做:
if(!(obj.get('isDestroyed')|| obj.get('isDestroying'))){
//你的破坏代码设置东西
}
还要考虑摧毁可能在视图代码中初始化的任何jQuery插件(任何设置在 didInsertElement
应该是茶例如, willDestroyElement
中的下降)。
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');
}
});
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).
这篇关于未捕获错误:断言失败:在已销毁对象上调用set的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!