JSONMatcher.js 496 B

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