I donβt think there is, but you can easily create it by creating an assistant :
var chai = require('chai'), expect = chai.expect, assert = chai.assert, Assertion = chai.Assertion Assertion.addMethod('equalAsSets', function (otherArray) { var array = this._obj; expect(array).to.be.an.instanceOf(Array); expect(otherArray).to.be.an.instanceOf(Array); var diff = array.filter(function(i) {return !(otherArray.indexOf(i) > -1);}); this.assert( diff.length === 0, "expected #{this} to be equal to #{exp} (as sets, ie no order)", array, otherArray ); }); expect([1,2,3]).to.be.equalAsSets([1,3,2]); expect([1,2,3]).to.be.equalAsSets([3,2]); flag
Remember that this is not an unordered equality test; it establishes equality. Duplicate elements are allowed in any array; this passes, for example: expect([1,2,3]).to.be.equalAsSets([1,3,2,2]);
source share