我的 ExtJS 应用程序在 Siesta 中有几个测试文件。其中一些测试必须在其他测试开始之前运行并通过。有没有办法只有在之前的测试通过后才能执行测试?
问问题
532 次
1 回答
1
在Siesta中,您可以使用测试来运行异步代码,并且可以进行链接和等待。有关更多信息,您可以查看入门指南,但为了完整起见,我在此处也包含了一个示例。
使用wait,其中一种异步方法:
t.wait('xhrSample');
Ext.Ajax.request({
url : 'ajax_demo/sample.json',
success : function (response, opts) {
t.is(response, 'foobar', 'Response is correct');
t.endWait('xhrSample');
},
failure : function (response, opts) {
t.fail("request failed");
t.endWait('xhrSample');
}
});
在午睡中使用链:
t.chain(
function (next) {
t.type(userNameField, 'username', next)
},
function (next) {
t.type(passwordField, 'secret', next)
},
function (next) {
t.click(loginButton, next)
},
function () {
// done
}
});
并持续使用waitFor:
this.waitFor(
// The condition to check for, this line will mean waiting until the presence of #foo element
function() { return document.getElementById('foo'); },
// The callback, after the condition has been fulfilled
function(el) { /* DO COOL STUFF */ }
);
如果您还有其他问题,我可能需要更多关于您正在等待午睡完成的信息。
于 2015-01-06T22:05:07.020 回答