2016-10-02 38 views
0

我面臨一個問題,當我試圖做deepEqual我試圖比較結果數據的確切結構帶有樣本數據。錯誤:未被捕獲的AssertionError:預期的{對象(響應)}等於{對象(響應)}

以上是我使用實際數據的結果創建的樣本json數據。

代碼:

it('comparing structures',()=>{ 
     var result = instance.parseResponse(input,esResponse); 
     console.log(result); 
     assert.deepEqual(result, expectedJSON); 
    }); 

在這裏,在控制檯我得到的結果。

enter image description here

以結果我創建採樣數據。

代碼:

var expectedJSON={ 
    "response":{ 
    "aggregate":{ 
     "average":43.833333333333336, 
     "count":6, 
     "max":90, 
     "min":10, 
     "total":263 
    }, 
    "endDate":"Tue Jul 05 2016 05:30:00 GMT+0530 (India Standard Time)", 
    "groupBy":"datetime", 
    "metricType":"distance_metric", 
    "quarters":[{ 
     "aggregate":{ 
      "average":0, 
      "count":undefined, 
      "max":0, 
      "min":0, 
      "total":0 
     }, 
     "quarter":4, 
     "startDate":"Invalid Date" 
    }], 
    "startDate":"Tue Jan 12 2016 05:30:00 GMT+0530 (India Standard Time)", 
    "type":"person" 
} 
}; 

我這樣做,因爲我需要創建精確的JSON結構,讓任何地方都可能是導致結構應匹配。

但我得到當你使用它deepEqual檢查不僅物體的結構,而且對象的類型故障測試案例

回答

0

。在這種情況下,它由__proto__

+0

是在我的實際結構中它是響應是DateMatric和在我的預期結構中它只是一個對象,所以這很重要? –