Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display error message correctly #3314

Merged
merged 5 commits into from May 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/utils/src/descriptors.ts
Expand Up @@ -94,5 +94,5 @@ export function getConcordanceTheme() {
}

export function diffDescriptors(actual: unknown, expected: unknown, options: DisplayOptions): string {
return concordanceModule.diff(expected, actual, options)
return concordanceModule.diff(actual, expected, options)
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved
}
28 changes: 14 additions & 14 deletions test/core/test/__snapshots__/mocked.test.ts.snap
Expand Up @@ -6,8 +6,8 @@ exports[`mocked function which fails on toReturnWith > just one call 1`] = `
Received:
1st spy call return:

- 2
+ 1
- 1
+ 2


Number of calls: 1
Expand All @@ -20,18 +20,18 @@ exports[`mocked function which fails on toReturnWith > multi calls 1`] = `
Received:
1st spy call return:

- 2
+ 1
- 1
+ 2

2nd spy call return:

- 2
+ 1
- 1
+ 2

3rd spy call return:

- 2
+ 1
- 1
+ 2


Number of calls: 3
Expand All @@ -45,22 +45,22 @@ Received:
1st spy call return:

{
- a: '4',
+ a: '1',
- a: '1',
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved
+ a: '4',
}

2nd spy call return:

{
- a: '4',
+ a: '1',
- a: '1',
+ a: '4',
}

3rd spy call return:

{
- a: '4',
+ a: '1',
- a: '1',
+ a: '4',
}


Expand Down
19 changes: 9 additions & 10 deletions test/core/test/diff.test.ts
Expand Up @@ -15,8 +15,8 @@ test('displays object diff', () => {

{
a: 1,
- b: 3,
+ b: 2,
- b: 2,
+ b: 3,
}"
`)
})
Expand All @@ -31,8 +31,8 @@ test('display one line string diff', () => {
" - Expected - 1
+ Received + 1

- 'string2'
+ 'string1'"
- 'string1'
+ 'string2'"
`)
})

Expand All @@ -43,13 +43,12 @@ test('display multiline line string diff', () => {
setupColors(getDefaultColors())
displayDiff(unifiedDiff(string1, string2), console as any)
expect(console.error.mock.calls[0][0]).toMatchInlineSnapshot(`
" - Expected - 2
" - Expected - 1
+ Received + 2

+ string1
\`string2
- string2
- string1\`
+ string3\`"
- \`string1
string2
- string3\`
+ \`string2"
`)
})
2 changes: 1 addition & 1 deletion test/core/test/jest-matcher-utils.test.ts
Expand Up @@ -5,7 +5,7 @@ describe('jest-matcher-utils', () => {
expect.extend({
toBeJestEqual(received: any, expected: any) {
return {
message: () => this.utils.diff(expected, received),
message: () => this.utils.diff(received, expected),
pass: received === expected,
}
},
Expand Down
8 changes: 4 additions & 4 deletions test/reporters/tests/__snapshots__/html.test.ts.snap
Expand Up @@ -46,8 +46,8 @@ exports[`html reporter > resolves to "failing" status for test file "json-fail"
"diff": " - Expected - 1
+ Received + 1

- 1
+ 2",
- 2
+ 1",
"expected": "1",
"message": "expected 2 to deeply equal 1",
"name": "AssertionError",
Expand All @@ -66,8 +66,8 @@ exports[`html reporter > resolves to "failing" status for test file "json-fail"
"diff": " - Expected - 1
+ Received + 1

- 1
+ 2",
- 2
+ 1",
"expected": "1",
"message": "expected 2 to deeply equal 1",
"name": "AssertionError",
Expand Down