I have a test that is comparing two sets, and when it fails the output is of the form:
- Expected
+ Received
Set {
Position {
"x": 0,
- "y": 0,
+ "y": 2,
},
Position {
- "x": 1,
- "y": 1,
+ "x": 0,
+ "y": 0,
},
Position {
- "x": 2,
+ "x": 1,
"y": 1,
},
Position {
- "x": 2,
- "y": 0,
+ "x": 1,
+ "y": 2,
},
}
I find this very hard to read as it's just a text diff and the real discrepancy is obscured (the sets differ by 2 elements but the output makes it hard to tell which)
This is an app I created via create-react-app, and I'm running the tests using npm test or yarn test. I thought that the command line arg --expand would do the trick but this doesn't seem to change the output (using yarn test -- --expand for instance) I thought the issue was passing command line args thru npm and yarn but --silent seems to be working as expected so I think that's working.
I'm totally new to this modern front-end environment so forgive me if I'm mixing up tools here ...
This is the test, in case it's relevant:
test('calculate neighbors on the edge of the board', () => {
let actual = neighbors(new Position(0,1));
let expected = new Set([
new Position(0,0),
new Position(1,1),
new Position(2,1),
new Position(2,0),
]);
console.log(actual);
console.log(expected);
expect(actual).toEqual(expected);
})
Those console.logs are suppressed by --silent which is why I think the args are being passed through. But maybe I misunderstand --expand ?
contents of package.json:
{
"name": "tzaar-js",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"@types/jest": "^26.0.10",
"immutable": "^4.0.0-rc.12",
"konva": "^7.0.3",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-konva": "^16.13.0-3",
"react-scripts": "3.4.1",
"typescript": "^3.9.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}