柴js期望属性值为空数组 [英] chai js expect property value empty array
本文介绍了柴js期望属性值为空数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用chai js断言编写单元测试,并且想知道如何期望长度为零的数组作为值.
I'm trying to write a unit test using chai js assertion, and was wondering how to expect arrays with zero length as values.
我的测试函数的期望语句:
My Test function expect statement:
return expect(functionRetuningPromise()).to eventually.have.property("key1", []);
正在运行摩卡游戏机的控制台输出:
Console Output on running mocha:
AssertionError: expected { otherkey: otherVal, key1: [] } to have a property 'key1' of [], but got []
我尝试deep.property
,key1:"[]"
均未成功
推荐答案
我忽略了属性声明中的一部分更改.因此,对我来说起作用的是:
I ignored there's a section of change in assertion for properties. So, what made it work for me was :
return expect(functionRetuningPromise()).to.eventually.have.property("key1").that.eql([]);
这篇关于柴js期望属性值为空数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文