Skip to content

Commit

Permalink
fix: fix assertion error message of toMatchObject
Browse files Browse the repository at this point in the history
  • Loading branch information
geersch committed Apr 7, 2024
1 parent 492d33e commit 725605f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/expect/src/jest-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const JestChaiExpect: ChaiPlugin = (chai, utils) => {
],
)
if ((pass && isNot) || (!pass && !isNot)) {
const message = stripped === 0 ? msg : `${msg}\n(${stripped} more ${pluralize('property', stripped)} properties in actual)`
const message = stripped === 0 ? msg : `${msg}\n(${stripped} matching ${pluralize('property', stripped)} omitted from actual)`
throw new AssertionError(message, { showDiff: true, expected, actual: actualSubset })
}
})
Expand Down
12 changes: 6 additions & 6 deletions test/core/test/jest-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ it('toMatchObject error diff', () => {
expect(getError(() => expect({ a: 1, b: 2, c: 3 }).toMatchObject({ c: 4 }))).toMatchInlineSnapshot(`
[
"expected { a: 1, b: 2, c: 3 } to match object { c: 4 }
(2 more properties properties in actual)",
(2 matching properties omitted from actual)",
"- Expected
+ Received
Expand All @@ -941,7 +941,7 @@ it('toMatchObject error diff', () => {
expect(getError(() => expect({ a: 1, b: 2, c: { d: 4 } }).toMatchObject({ b: 3 }))).toMatchInlineSnapshot(`
[
"expected { a: 1, b: 2, c: { d: 4 } } to match object { b: 3 }
(3 more properties properties in actual)",
(3 matching properties omitted from actual)",
"- Expected
+ Received
Expand All @@ -956,7 +956,7 @@ it('toMatchObject error diff', () => {
expect(getError(() => expect({ a: 1, b: 2, c: { d: 4, e: 5 }, f: { g: 6 } }).toMatchObject({ c: { d: 5 } }))).toMatchInlineSnapshot(`
[
"expected { a: 1, b: 2, c: { d: 4, e: 5 }, …(1) } to match object { c: { d: 5 } }
(5 more properties properties in actual)",
(5 matching properties omitted from actual)",
"- Expected
+ Received
Expand Down Expand Up @@ -989,7 +989,7 @@ it('toMatchObject error diff', () => {
expect(getError(() => expect({ a: 1, b: 2, c: { d: 3 } }).toMatchObject({ a: 1, c: { d: 4 } }))).toMatchInlineSnapshot(`
[
"expected { a: 1, b: 2, c: { d: 3 } } to match object { a: 1, c: { d: 4 } }
(1 more property properties in actual)",
(1 matching property omitted from actual)",
"- Expected
+ Received
Expand All @@ -1007,7 +1007,7 @@ it('toMatchObject error diff', () => {
expect(getError(() => expect({ a: 1, b: 2, c: { d: 4 }, foo: { value: 'bar' }, bar: { value: 'foo' } }).toMatchObject({ c: { d: 5 }, foo: { value: 'biz' } }))).toMatchInlineSnapshot(`
[
"expected { a: 1, b: 2, c: { d: 4 }, …(2) } to match object { c: { d: 5 }, foo: { value: 'biz' } }
(4 more properties properties in actual)",
(4 matching properties omitted from actual)",
"- Expected
+ Received
Expand All @@ -1029,7 +1029,7 @@ it('toMatchObject error diff', () => {
expect(getError(() => expect(characters).toMatchObject({ family: 'House Atreides', children: [{ firstName: 'Paul' }] }))).toMatchInlineSnapshot(`
[
"expected { firstName: 'Vladimir', …(4) } to match object { family: 'House Atreides', …(1) }
(5 more properties properties in actual)",
(5 matching properties omitted from actual)",
"- Expected
+ Received
Expand Down

0 comments on commit 725605f

Please sign in to comment.