Mocha / Chai - 超时,确保承诺解决

Mocha / Chai - Timeout, ensuring promise resolves

关于这个问题有几千个问题,我想我已经阅读了所有问题,但我仍然不明白为什么以下内容不起作用。

这段代码在本地执行没有问题。当在 TravisCI 上 运行 - 它失败并出现 ensure done() is being called 错误。

it('Function oLab.GetObjects & oLab.Deploy', (done) => {
    var l = new oLab('1')
    l.getObjects().then(function(data){
        console.log(data);
        expect(data.length).to.above(0);
        //There is a bunch of other code in here commented out since this alone doesn't work.  
    })
    .then(() => done(), done)
    .catch(function (err) {     }); // Not executed
});

我知道 getObjects 函数失败了:

this.getObjects = function () {
    console.log("oLab getObjects function");
    return getResources(this.id);
}

调用 getResources:

function getResources(labID){
    return db.any('select * from lab_resources where lab_id = ' + labID).then(function(data){
        var resources = [];
        //Modifies the resources and returns the list.  Logging this displays the correct data.  
        return resources;
    })
    .catch(function (err) {     }); // Not executed

}

问题:

  1. 我读了这个 blog 并基于它添加(完成)到我的功能中,因为我认为我 return 一个承诺。如果它是嵌套的,我会 return 承诺吗? IE 我调用 getObjects,然后调用 getResources。 getResources returns 是一个数据库查询,但在其中 - 有一个值 returned。这是否意味着我正在 return 调用函数的承诺或值?我认为它会 return 承诺,因为承诺不会立即执行。
  2. 在 getObjects 中,我试图设置一个 属性 oLab。我应该在 getObjects 函数中设置 属性 还是应该 return 我的调用方法然后更改 oLab 的 属性?

事实证明 Travis CI 无法访问我请求的数据库,因此数据库连接设置失败。