2016-03-18 96 views
0

背景Chai.js:如何正確使用`和`吸氣劑語言鏈

我很感激學習如何使用and吸氣劑在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 is not a function

問題

如何正確使用and吸氣,以測試是否myVariable是一個"number",並在同一時間確保它不是一個NaN

回答

0

答案是:

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