UNPKG

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