frisbyjs对象数组

我的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" } } 

现在我想testing数组的所有元素的数据的属性的types。

我的弗里斯比testing看起来像这样:

 //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) 

我该怎么做?

path的每一段都被拆分。 你可以在frisby / lib / frisby.js的源代码中find它

  _.each(path.split('.'), function(segment) { 

所以要做你的testing会是这样的:

 .expectJSON('data.0', {last_name: "Miras"}) .expectJSONTypes('data.0', { id: Number, first_name: String .. 

删除你的第一个参数'*',因为这意味着你期待一个数组,

当响应是一个数组时,它会比较数组中的所有logging,所以你可以使用'*'的索引'0'