量角器测试,Jasmine和异步解决方案 [英] Protractor tests , Jasmine and asynchronous solution
本文介绍了量角器测试,Jasmine和异步解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在工作量角器中使用了茉莉花.发现烦人和不安的是我必须始终编写测试的方式.我真的不喜欢这样做,因为waitsFor得到了getCssValue的承诺.有人可以向我展示更好的异步测试解决方案吗?目前正在使用Jasmine 2.0"
I using in my work protractor with jasmine . What found annoying and disturbing is ways I have to write always tests. I really don't like to do this waitsFor for promise from getCssValue. Can someone can show me better solution for asynchronous tests then this. At moment using Jasmine 2.0"
describe('And I see a "Burger Menu" option on the Header section', function () {
it('And the Left Hand Navigation is not visible When I access a Burger menu option on the ' +
'Header section Then I want to see the Left Hand Navigation menu', function () {
runs(function () {
Homepage.burger.click();
});
waits(500);
runs(function () {
Homepage.leftHandNav.getCssValue('display').then(function (item) {
displayStatus = item;
});
});
waitsFor(function () {
return displayStatus;
}, 200);
runs(function () {
expect(displayStatus).toBe('block');
});
});
对于这种功能,这似乎是非常复杂的代码.
It seems like very complicated code for such functionality.
推荐答案
您尝试过吗?
expect(Homepage.leftHandNav.getCssValue('display')).toBe('block');
使用最新版本似乎可以正常工作.
With the most recent versions it looks like working.
AFAIK期望在内部等待相关的诺言.
AFAIK expect waits internally for the related promises.
这篇关于量角器测试,Jasmine和异步解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文