Node.js [量角器]如何避免;console.log";验证失败后的输出

Node.js [量角器]如何避免;console.log";验证失败后的输出,node.js,protractor,Node.js,Protractor,我正在做基于量角器+硒+茉莉花的e2e测试。我有以下代码 describe("test google search box", function () { function firstPart() { console.log("before starting"); browser.get("http://www.google.com"); console.log("after running"); } functi

我正在做基于量角器+硒+茉莉花的e2e测试。我有以下代码

    describe("test google search box", function () {
    function firstPart() {
        console.log("before starting");
        browser.get("http://www.google.com");
        console.log("after running");
    }

    function secondPart() {
        console.log("begin validation");
        var searchBox = element(By.id('kw'));
        **expect(searchBox.getAttribute("id")).toEqual("kw1"); //this is a intentional failure**
        console.log("after validation");

    }


    beforeEach(function () {
        return browser.ignoreSynchronization = true;
    });

    it("if search box exists", function () {
        var flow = browser.controlFlow();
        protractor.promise.all(flow.execute(firstPart), flow.execute(secondPart));
    });
}); 
我不想执行“console.log(“验证后”);”因为前一步是故意失败的。如何做到这一点


感谢您的帮助。

如果您只想记录已解决的承诺,请将日志记录在承诺中:

function log(message) {
  browser.controlFlow().execute(function(){
    console.log(message);
  });
}

function firstPart() {
    log("before starting");
    browser.get("http://www.google.com");
    log("after running");
}

function secondPart() {
    log("begin validation");
    var searchBox = element(By.id('kw'));
    expect(searchBox.getAttribute("id")).toEqual("kw1"); //this is a intentional failure**
    log("after validation");
}

it("if search box exists", function () {
    firstPart();
    secondPart();
});
输出:

Started
before starting
after running
begin validation
F

Failures:
...

jasminewd即将推出一个功能,用于量角器。但目前,如果没有黑客的帮助,你就不能很好地做到这一点-