2014-07-18 77 views
0
//spec 

it('check process data to see if it returns correct JSON object', function() { 

var dataExpected = []; 

    dataExpected.push({ 
     image : "https://katmou.files.wordpress.com/2011/11/blade_runner.jpeg", 
     title : "Harrison", 
     id : 1 

    }); 

    expect(dataAfter).toEqual(dataExpected); 
}); 

錯誤:茉莉的幫助,希望不工作

[ERROR] : . THERE WERE FAILURES! 
[ERROR] : . ============================================================ 
[ERROR] : . Recap of failing specs: 
[ERROR] : . ------------------------------------------------------------ 
[ERROR] : . viewP controller check process data to see if it returns correct JSON object. - Expected [ { image : 'https://katmou.files.wordpress.com/2011/11/blade_runner.jpeg', title : 'Harrison', id : '1' } ] to equal [ { image : 'https://katmou.files.wordpress.com/2011/11/blade_runner.jpeg', title : 'Harrison', id : 1 } ]. 

的數據之後是相同的期望是什麼,它仍然是失敗的,爲什麼呢?

乾杯。

+0

您是否試過使用'expect(dataAfter).toMatch(dataExpected);'? – Sobieck

回答

1

您所期待的id屬性爲1,但結果是'1'

+0

斑點。這是問題所在。 – user3754111