[英]Angular 1/Jasmine - Test return type of function
我想測試函數的返回類型,是布爾值還是數字...
使用此代碼,我可以測試函數是否存在,如何通過測試返回類型來推動測試?
it('should expose a showMonthlyRentDate function', () => {
expect(ctrl.showMonthlyRentDate).toBeDefined()
expect(typeof ctrl.showMonthlyRentDate).toBe('function')
})
它是
expect(ctrl.showMonthlyRentDate()).toEqual(jasmine.any(Number));
最好使用jasmine.any
因為它會在測試失敗時提供更有意義的反饋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.