Chai,matchers 是否与 rspecs =~
等价(这意味着包含所有元素,但顺序无关紧要。
传递示例
[1, 2, 3].should =~ [2, 1, 3]
失败
[1, 2, 3].should =~ [1, 2]
最佳答案
您可以使用最新版 Chai 中提供的 members
测试:
expect([4, 2]).to.have.members([2, 4]);
expect([5, 2]).to.not.have.members([5, 2, 1]);
关于javascript - 等同于 rspec =~ 对于 Chai 中的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11505554/