Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing 随机失败的验收测试,错误为:断言失败:调用已销毁对象上的集合_Testing_Ember.js - Fatal编程技术网

Testing 随机失败的验收测试,错误为:断言失败:调用已销毁对象上的集合

Testing 随机失败的验收测试,错误为:断言失败:调用已销毁对象上的集合,testing,ember.js,Testing,Ember.js,我的一些验收测试(涉及操作)在与所有其他测试一起运行时会随机失败,但在单独运行时不会失败 错误:断言失败:在我的操作中触发对已销毁对象的调用集 作为用户使用该表时,我没有遇到任何问题,因此这些问题仅出现在测试中。所以我不确定这是否只是因为每次运行后应用程序没有正确销毁 我能知道为什么这个物体即将被摧毁,或者哪些观察家正在阻止它吗 foos/index/route.js startFoo(foos) { foos.forEach(function(foo) { foo.set('sta

我的一些验收测试(涉及操作)在与所有其他测试一起运行时会随机失败,但在单独运行时不会失败

错误:断言失败:在我的操作中触发对已销毁对象的调用集

作为用户使用该表时,我没有遇到任何问题,因此这些问题仅出现在测试中。所以我不确定这是否只是因为每次运行后应用程序没有正确销毁

我能知道为什么这个物体即将被摧毁,或者哪些观察家正在阻止它吗

foos/index/route.js

startFoo(foos) {
  foos.forEach(function(foo) {
    foo.set('status', 'active');
    foo.save();
  });
},
visibleColumns: Ember.A(),
selectedRows: Ember.A(),

selectRow(row) {
  let selectedRows = this.get('selectedRows');
  if (selectedRows.contains(row)) {
    selectedRows.removeObject(row);
  } else {
    selectedRows.addObject(row);
  }
},
isSelected(row) {
  return this.get('selectedRows').contains(row);
},
isSelected: computed('table.selectedRows.[]', {
  get(/*key*/) {
    return this.get('table').isSelected(this.get('content'));
  },
  set(/*key, value*/) {
    this.get('table').selectRow(this.get('content'));
    return this.get('table').isSelected(this.get('content'));
  },
}),
操作
被传递到一个组件(表),其中显示了
foo
-模型的列表。可以选择每一行,这样可以将此行的
foo
模型添加到此表组件上的属性
selectedRows

组件/my table/table.js

startFoo(foos) {
  foos.forEach(function(foo) {
    foo.set('status', 'active');
    foo.save();
  });
},
visibleColumns: Ember.A(),
selectedRows: Ember.A(),

selectRow(row) {
  let selectedRows = this.get('selectedRows');
  if (selectedRows.contains(row)) {
    selectedRows.removeObject(row);
  } else {
    selectedRows.addObject(row);
  }
},
isSelected(row) {
  return this.get('selectedRows').contains(row);
},
isSelected: computed('table.selectedRows.[]', {
  get(/*key*/) {
    return this.get('table').isSelected(this.get('content'));
  },
  set(/*key, value*/) {
    this.get('table').selectRow(this.get('content'));
    return this.get('table').isSelected(this.get('content'));
  },
}),
组件/my table/header/template.hbs

startFoo(foos) {
  foos.forEach(function(foo) {
    foo.set('status', 'active');
    foo.save();
  });
},
visibleColumns: Ember.A(),
selectedRows: Ember.A(),

selectRow(row) {
  let selectedRows = this.get('selectedRows');
  if (selectedRows.contains(row)) {
    selectedRows.removeObject(row);
  } else {
    selectedRows.addObject(row);
  }
},
isSelected(row) {
  return this.get('selectedRows').contains(row);
},
isSelected: computed('table.selectedRows.[]', {
  get(/*key*/) {
    return this.get('table').isSelected(this.get('content'));
  },
  set(/*key, value*/) {
    this.get('table').selectRow(this.get('content'));
    return this.get('table').isSelected(this.get('content'));
  },
}),
action.cb
是函数
startFoo

<button {{action action.cb table.selectedRows}}>
  {{im-icon icon=action.icon}}
</button>
组件/我的表格/行/模板.hbs

startFoo(foos) {
  foos.forEach(function(foo) {
    foo.set('status', 'active');
    foo.save();
  });
},
visibleColumns: Ember.A(),
selectedRows: Ember.A(),

selectRow(row) {
  let selectedRows = this.get('selectedRows');
  if (selectedRows.contains(row)) {
    selectedRows.removeObject(row);
  } else {
    selectedRows.addObject(row);
  }
},
isSelected(row) {
  return this.get('selectedRows').contains(row);
},
isSelected: computed('table.selectedRows.[]', {
  get(/*key*/) {
    return this.get('table').isSelected(this.get('content'));
  },
  set(/*key, value*/) {
    this.get('table').selectRow(this.get('content'));
    return this.get('table').isSelected(this.get('content'));
  },
}),
content
是一种
foo
模型

<td class="shrink">{{input type='checkbox' checked=isSelected}}</td>
{{#each table.visibleColumns as |column|}}
  {{my-table/cell content=content column=column}}
{{/each}}

在设置之前检查
isDestroyed
,应该可以实现这一功能

isSelected: computed('table.selectedRows.[]', {
  get(/*key*/) {
    return this.get('table').isSelected(this.get('content'));
  },
  set(/*key, value*/) {
    if (this.get('isDestroyed')) {
      return;
    }
    this.get('table').selectRow(this.get('content'));
    return this.get('table').isSelected(this.get('content'));
  },
}),

这显然会解决这个问题,但看起来更像是一种黑客行为。我真的不想因为测试失败而使用特殊代码,因为我的应用程序可以正常工作。我已经在旧的应用程序中进行了检查,仍然感觉有些东西不是以“余烬”的方式构建的