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 the order of arguments in the Jest matcher util #1245

Merged
merged 1 commit into from May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Expand Up @@ -170,5 +170,5 @@ export interface DiffOptions {
// TODO: do something with options
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function diff(a: any, b: any, options?: DiffOptions) {
return unifiedDiff(stringify(a), stringify(b))
return unifiedDiff(stringify(b), stringify(a))
}
19 changes: 19 additions & 0 deletions test/core/test/jest-matcher-utils.test.ts
@@ -0,0 +1,19 @@
import { describe, expect, it } from 'vitest'

describe('jest-matcher-utils', () => {
expect.extend({
toBeJestEqual(received: any, expected: any) {
return {
message: () => this.utils.diff(expected, received),
pass: received === expected,
}
},
})

it('diff', () => {
expect(() => {
// @ts-expect-error "toBeJestEqual" is a custom matcher we just created
expect('a').toBeJestEqual('b')
}).toThrowError(/Expected.*"b".*Received.*"a"/ms)
})
})