Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用expect.js并且我想测试集合等价性
expect.js
Error: expected [ [ 1, 2 ], [ 2, 1 ], [ 0, 1 ], [ 1, 0 ] ] to sort of equal [ [ 1, 2 ], [ 2, 1 ], [ 1, 0 ], [ 0, 1 ] ]
^ 这应该是真的。
我找到了这个,但我如何将它整合到expect.js?
您可以通过对数组进行排序来作弊..(以下是咖啡脚本)
describe 'test', -> it 'should match', -> a = [ [ 1, 2 ], [ 2, 1 ], [ 0, 1 ], [ 1, 0 ] ] b = [ [ 1, 2 ], [ 2, 1 ], [ 1, 0 ], [ 0, 1 ] ] expect(a.sort()).to.eql b.sort()