Chai.js:如何在语言链中正确使用“and”getter



Background

我将不胜感激学习如何使用and getter作为Chai语言链的一部分。我试过这段代码:

describe ('', function () {
    it ('', function () {
        expect(myVariable).to.be.a('number').and.not.a(NaN);
        expect(myVariable).to.be.a('number').and.not.to.be.a(NaN);
    }
}

但这两个表达式都会导致以下错误消息:

TypeError: type.toLowerCase 不是函数

问题

如何正确使用and吸气器来测试myVariable是否是"number",同时确保它不是NaN

答案是:

expect(myVariable).to.be.a('number').and.not.a.NaN;

最新更新