完成 mocha 脚本完成 returns 解决方法指定过多

finishing the mocha script done returns Resolution method is overspecified

访问两个链接,然后在完成后调用它完成 returns 我 "Resolution method is overspecified. Specify a callback or return a Promise; not both"

describe("youtube", function(){
    this.timeout(8000);
    it("test successful login",function(done){
        var driver = new webdriver.Builder().forBrowser("chrome").build();
        driver.get("http://www.google.com");

        const pageLoad = By.id('lga')
        return driver.wait(until.elementLocated(pageLoad)).then(()=>{

            return setTimeout(function(){
                driver.get("http://www.facebook.com");

                const signedPageLoad = By.id('pagelet_bluebar')

                return driver.wait(until.elementLocated(signedPageLoad)).then(()=>{
                      //assert.strictEqual(, message);


                                                    done(); // call this function to tell mocha that you are done. 
                })
            },1000)
        })
    })
})

怎么会这样?

返回 promisedone 不兼容。

我认为您应该从代码中删除所有 return 语句

@AbhinavD 帮助我理解了我能够通过添加断言和捕获错误来更灵活地编辑代码。

it("test successful login",function(done){
    var driver = new webdriver.Builder().forBrowser("chrome").build();
    driver.get("http://www.google.com");

    const pageLoad = By.id('lga')
    driver.wait(until.elementLocated(pageLoad)).then(()=>{

        setTimeout(function(){
            driver.get("http://www.facebook.com");

            const signedPageLoad = By.id('pagelet_bluebar')

            driver.wait(until.elementLocated(signedPageLoad)).then(()=>{
                  //assert.strictEqual(, message);
                    assert.equal(50, 70); 
                    done(); // call this function to tell mocha that you are done. 
            }).catch((err) => done(err));
        },1000)
    }).catch((err) => done(err));
})