Why is should.be.type() failing with "TypeError: (intermediate value).should.be.type is not a function"

Why is should.be.type() failing with "TypeError: (intermediate value).should.be.type is not a function"

我不明白为什么以下测试失败并出现错误:

TypeError: (intermediate value).should.be.type is not a function

describe('#Option object', function() {
    it('returns value as whatever type was passed to the constructor', function() {
        var o = function() {
            this.getValue = function() {
                return new Date();
            }
        };

        var i = new o();
        i.getValue().should.be.type('Date');
    })
});

我已经阅读了 Should.js documentation 的 [大部分],但我一定漏掉了什么。谁能告诉我我的测试有什么问题?

其实只有一件事错了。您阅读的不是 should.js 文档,而是 unit.js 文档 - 它与 should.js 完全无关。 正确link。 正确的代码将是:

i.getValue().should.be.instanceOf(Date);

i.getValue().should.be.Date();