JSONMatcher.js 509 B

12345678910111213141516171819
  1. export default function(chai, utils) {
  2. var Assertion = chai.Assertion;
  3. Assertion.addMethod('jsonEqual', function(comparison, filter) {
  4. var actual = JSON.stringify(this._obj, filter, ' ');
  5. var expected = JSON.stringify(comparison, filter, ' ');
  6. this.assert(
  7. actual == expected,
  8. 'expected #{this} to json equal #{exp} but got #{act}',
  9. 'expected #{this} not to json equal #{exp}',
  10. expected, // expected
  11. actual, // actual
  12. true // show diff
  13. );
  14. });
  15. }