2014-04-16 47 views
0

我在我的工作中使用茉莉花量角器。发现烦人和令人不安的是我必须编写总是测试的方法。我真的不喜欢这样做等待getCssValue的承诺。有人可以向我展示更好的异步测试解决方案吗?在使用茉莉花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'); 
    }); 
}); 

这似乎是这样的功能非常复杂的代码。

回答

2

你试过吗?

expect(Homepage.leftHandNav.getCssValue('display')).toBe('block'); 

随着最新版本,它看起来像工作。

AFAIK预计在内部等待相关承诺。