Testing 余烬测试:在呈现某些内容之前,如何暂停测试?
我正在尝试创建一个简单的测试来创建新记录Testing 余烬测试:在呈现某些内容之前,如何暂停测试?,testing,ember.js,Testing,Ember.js,我正在尝试创建一个简单的测试来创建新记录 test('Create dataset', function(assert) { expect(1); visit('/add'); fillIn('input.name', 'some name'); fillIn('input.description', 'some description'); //this part is to click on custom dropdown and select first opti
test('Create dataset', function(assert) {
expect(1);
visit('/add');
fillIn('input.name', 'some name');
fillIn('input.description', 'some description');
//this part is to click on custom dropdown and select first option
click('.select2-container input'); //after this action a list of options is generated
click('.select2-drop ul li:first'); //but this action runs before the list was generated, so it gives me an error that this element does not exist
click('button[type="submit"]');
});
有没有办法暂停测试直到列表呈现出来
例如,waitFor('.select2-drop-ul-li:first')
UPD:我发现select2在“body”中生成了下拉列表。余烬测试在div#Ember测试中运行。这就是为什么我的测试脚本看不到select2的内容。要处理异步行为,请使用帮助程序 Ember.run.later(函数(){//5秒后重试,5000)<代码>然后(()=>单击('.选择2 drop ul li:first')代码>应该可以做到这一点
test('Create dataset', function(assert) {
expect(1);
visit('/add');
andThen(function() {
fillIn('input.name', 'some name');
fillIn('input.description', 'some description');
//this part is to click on custom dropdown and select first option
click('.select2-container input'); //after this action a list of options is generated
click('.select2-drop ul li:first'); //but this action runs before the list was generated, so it gives me an error that this element does not exist
click('button[type="submit"]');
});
});