Chai承诺不等待先前的承诺解决
问题描述:
我有以下功能,我正在使用它的预期。Chai承诺不等待先前的承诺解决
function Create() {
var that = this;
// Goto home page of App.
// Async call
that.homePage();
// Async call
Utils.click(projectsSelectors.project_create, false, that.browser);
// Async call
Utils.elementIsVisible(stock_avatar, that.browser);
// Async call
Utils.fill(name_input, that.name, that.browser);
// Async call
stockAvatar.call(that);
// Async call
Utils.click(create_save, false, that.browser);
// Verify if it's created.
// Async call
return that.$is_Created();
}
但是,当我使用如下
expect(Create()).to.eventually.equal(true);
期望是没有做任何事情刚刚过去。上面的Create方法包含多个异步调用。
我甚至在Create方法内部链接了所有的调用,但是仍然期望只是在屏幕上没有做任何事情而传递。
答
你的测试方法必须return the promise
it("should do something", function()
{
return expect(Create()).to.eventually.equal(true);
}