期望并应该使用 Promise 对象而不是解析结果

Expect and should use the Promise object instead of the resolved result

我的单元测试设置如下:

const mocha = require('mocha')
var chai = require('chai')
var chaiAsPromised = require('chai-as-promised')
chai.use(chaiAsPromised)

var expect = chai.expect
chai.should()

describe('chain test', function() {
  it('should be a string', function() {
    return Promise.resolve('string').should.to.be.a('string');
  });
});

但是当我运行摩卡时,结果是:

1) chain test should be a string:  
   AssertionError: expected {} to be a string

所以看起来测试是针对 Promise 对象本身而不是针对已解决的结果进行的。

根据chai-as-promised: Installation and Setup设置是正确的。

测试的创建方式与 chai-as-promised: How to Use 中描述的相同。

我已经测试了 expect(promise).promise.should 语法。有谁知道是什么问题?

使用的node版本和模块为:

我发现了错误。

问题是正确的语法不是 .should.to.be 而必须是 .should.eventually.be