show entire output of expected and received in failed test
Jest seems to have been changed in v24 to give less information. In Jest 23.6.0 the output you got is preceded by:
Expected value to equal:
Set {{"x": 0, "y": 0}, {"x": 1, "y": 1}, {"x": 2, "y": 1}, {"x": 2, "y": 0}}
Received:
Set {{"x": 0, "y": 2}, {"x": 0, "y": 0}, {"x": 1, "y": 1}, {"x": 1, "y": 2}}
This is not shown when the Jest version is changed to 24.9.0, which is the default with react-scripts v3.4.1 used in your package.json
.
A workaround in your test is to use two .toContain
matchers instead of a .toEqual
:
expect(actual).toContain(expected);
expect(expected).toContain(actual);
This produces (from the first assertion):
Expected value: Set {{"x": 0, "y": 0}, {"x": 1, "y": 1}, {"x": 2, "y": 1}, {"x": 2, "y": 0}}
Received set: Set {{"x": 0, "y": 2}, {"x": 0, "y": 0}, {"x": 1, "y": 1}, {"x": 1, "y": 2}}
Note that, unlike the .toEqual
equivalent, .toContain
fails if the order is different between the two sets, so you will need to convert the sets to arrays and sort them to compare properly.