Is there an Array equality match function that ignores element position in jest.js?

前端 未结 6 1765
栀梦
栀梦 2021-02-06 20:06

I get that .toEqual() checks equality of all fields for plain objects:

expect(
    {"key1":"pin         


        
6条回答
  •  抹茶落季
    2021-02-06 20:32

    Put the elements into a set. Jest knows how to match these.

    expect(new Set(["pink wool", "diorite"])).toEqual(new Set(["diorite", "pink wool"]));
    

提交回复
热议问题