Equivalent to rspec =~ for arrays in Chai

chai, javascript, mocha.js, testing

Solution

You can use `members` test that is available in the latest Chai version:

expect([4, 2]).to.have.members([2, 4]);
expect([5, 2]).to.not.have.members([5, 2, 1]);

Problem

Does Chai, matchers have an equilivent to rspecs `=~` (which means has all elements but order doesn't matter. Passing example ``` [1, 2, 3].should =~ [2, 1, 3] ``` Failing ``` [1, 2, 3].should =~ [1, 2] ```

Original source