chai: Make error message more descriptive
Sometimes error messages for hash comparison looks like that
expect(data.pagination).to.eql
currentPage : 2
perPage : 3
pagesCount : 3
currentPagePath : '/tag/News?page=2'
firstPagePath : '/tag/News'
previousPagePath : '/tag/News'
nextPagePath : '/tag/News?page=3'
lastPagePath : '/tag/News?page=3'
expected { Object (currentPage, perPage, ...) } to deeply equal { Object (currentPage, perPage, ...) }
looking at such message it’s hard to understand what’s wrong there.
Maybe add more details?
About this issue
- Original URL
- State: closed
- Created 12 years ago
- Comments: 20 (9 by maintainers)
Commits related to this issue
- showDiff: force diff for equal and eql. #106 — committed to chaijs/chai by logicalparadox 12 years ago
- browser build: (object diff support when used with mocha) #106 — committed to chaijs/chai by logicalparadox 12 years ago
Based on this StackOverflow answer, I believe the issue was occuring for me because my tests were asynchronous.
I got diffs working correctly again by using the following pattern: