我的 nodejs 服务器响应一个包含如下对象数组的对象:
{
error: false
message: "get dispatchers successful"
data: [1]
0: {
id: 1
first_name: "Brenth Andrew J."
last_name: "Miras"
contact_number: null
email: "brenthmiras2@gmail.com"
address: null
image: null
password: "bajmiras"
created: "2014-09-12T10:24:06.000Z"
}
}
现在我想测试数组数据的所有元素的“数据”属性的类型。
我的 frisby 测试如下所示:
//expect these types of response
.expectJSONTypes('*', {
error: Boolean,
message: String,
data: {
id: Number,
first_name: String,
last_name: String,
contact_number: String,
email: String,
address: String,
image: String,
password: String,
created: String
}
})
我得到这个错误:
TypeError: Expected '*' to be Array (got 'object' from JSON response)
我该怎么做?