From 39687e45618a846211eec5d19cf8e0dd50c7ece9 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 17 Feb 2026 13:27:22 +0900 Subject: [PATCH 1/4] fix(diff): remove trailing spaces before newline in Expected/Received headers --- packages/utils/src/diff/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/utils/src/diff/index.ts b/packages/utils/src/diff/index.ts index 6887e55537b4..4fd6ac9b2078 100644 --- a/packages/utils/src/diff/index.ts +++ b/packages/utils/src/diff/index.ts @@ -110,8 +110,8 @@ export function diff(a: any, b: any, options?: DiffOptions): string | undefined } aDisplay = truncate(aDisplay) bDisplay = truncate(bDisplay) - const aDiff = `${aColor(`${aIndicator} ${aAnnotation}:`)} \n${aDisplay}` - const bDiff = `${bColor(`${bIndicator} ${bAnnotation}:`)} \n${bDisplay}` + const aDiff = `${aColor(`${aIndicator} ${aAnnotation}:`)}\n${aDisplay}` + const bDiff = `${bColor(`${bIndicator} ${bAnnotation}:`)}\n${bDisplay}` return `${aDiff}\n\n${bDiff}` } From 89b5c0e8a3dc4206a3e83add5398d996aaa68aa3 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 17 Feb 2026 13:38:41 +0900 Subject: [PATCH 2/4] test: update snapshot --- .../components/views/ViewReport.spec.ts | 2 +- .../__snapshots__/jest-expect.test.ts.snap | 72 +++++++++---------- test/core/test/expect.test.ts | 8 +-- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/packages/ui/client/components/views/ViewReport.spec.ts b/packages/ui/client/components/views/ViewReport.spec.ts index bbb609754c7c..117983888ca4 100644 --- a/packages/ui/client/components/views/ViewReport.spec.ts +++ b/packages/ui/client/components/views/ViewReport.spec.ts @@ -27,7 +27,7 @@ const textStacks = Array.from({ length: 5 }, makeTextStack) const diff = ` \x1B[32m- Expected\x1B[39m \x1B[31m+ Received\x1B[39m - + \x1B[2m Object {\x1B[22m \x1B[2m "a": 1,\x1B[22m \x1B[32m- "b": 2,\x1B[39m diff --git a/test/core/test/__snapshots__/jest-expect.test.ts.snap b/test/core/test/__snapshots__/jest-expect.test.ts.snap index 5fb6d4f82793..5aec9b6bc32a 100644 --- a/test/core/test/__snapshots__/jest-expect.test.ts.snap +++ b/test/core/test/__snapshots__/jest-expect.test.ts.snap @@ -59,10 +59,10 @@ exports[`asymmetric matcher error 4`] = ` exports[`asymmetric matcher error 5`] = ` { "actual": "hello", - "diff": "- Expected: + "diff": "- Expected: stringContainingCustom<"xx"> -+ Received: ++ Received: "hello"", "expected": "stringContainingCustom<"xx">", "message": "expected 'hello' to deeply equal stringContainingCustom<"xx">", @@ -72,10 +72,10 @@ stringContainingCustom<"xx"> exports[`asymmetric matcher error 6`] = ` { "actual": "hello", - "diff": "- Expected: + "diff": "- Expected: not.stringContainingCustom<"ll"> -+ Received: ++ Received: "hello"", "expected": "not.stringContainingCustom<"ll">", "message": "expected 'hello' to deeply equal not.stringContainingCustom<"ll">", @@ -141,12 +141,12 @@ exports[`asymmetric matcher error 10`] = ` exports[`asymmetric matcher error 11`] = ` { "actual": "hello", - "diff": "- Expected: + "diff": "- Expected: testComplexMatcher -+ Received: ++ Received: "hello"", "expected": "testComplexMatcher -+ Received: ++ Received: "foo"", "expected": "toBeOneOf, null, undefined, ]> -+ Received: ++ Received: 0", "expected": "toBeOneOf, @@ -272,7 +272,7 @@ exports[`asymmetric matcher error 18`] = ` "k": "v", "k2": "v2", }", - "diff": "- Expected: + "diff": "- Expected: toBeOneOf -+ Received: ++ Received: { "k": "v", "k2": "v2", @@ -320,10 +320,10 @@ exports[`asymmetric matcher error 20`] = ` exports[`asymmetric matcher error 21`] = ` { "actual": "hello", - "diff": "- Expected: + "diff": "- Expected: stringContainingCustom<"xx"> -+ Received: ++ Received: "hello"", "expected": "stringContainingCustom<"xx">", "message": "expected error to match asymmetric matcher", @@ -342,10 +342,10 @@ exports[`asymmetric matcher error 22`] = ` exports[`asymmetric matcher error 23`] = ` { "actual": "hello", - "diff": "- Expected: + "diff": "- Expected: stringContainingCustom<"ll"> -+ Received: ++ Received: "hello"", "expected": "stringContainingCustom<"ll">", "message": "expected error not to match asymmetric matcher", @@ -355,10 +355,10 @@ stringContainingCustom<"ll"> exports[`asymmetric matcher error 24`] = ` { "actual": "[Error: hello]", - "diff": "- Expected: + "diff": "- Expected: StringContaining "ll" -+ Received: ++ Received: Error { "message": "hello", }", @@ -370,10 +370,10 @@ Error { exports[`asymmetric matcher error 25`] = ` { "actual": "[Error: hello]", - "diff": "- Expected: + "diff": "- Expected: stringContainingCustom<"ll"> -+ Received: ++ Received: Error { "message": "hello", }", @@ -385,10 +385,10 @@ Error { exports[`asymmetric matcher error 26`] = ` { "actual": "[Error: hello]", - "diff": "- Expected: + "diff": "- Expected: [Function MyError1] -+ Received: ++ Received: MyError2 { "message": "hello", }", @@ -400,10 +400,10 @@ MyError2 { exports[`diff 1`] = ` { "actual": "undefined", - "diff": "- Expected: + "diff": "- Expected: true -+ Received: ++ Received: undefined", "expected": "true", "message": "expected undefined to be truthy", @@ -415,10 +415,10 @@ exports[`diff 2`] = ` "actual": "Object { "hello": "world", }", - "diff": "- Expected: + "diff": "- Expected: false -+ Received: ++ Received: { "hello": "world", }", @@ -432,10 +432,10 @@ exports[`diff 3`] = ` "actual": "Object { "hello": "world", }", - "diff": "- Expected: + "diff": "- Expected: NaN -+ Received: ++ Received: { "hello": "world", }", @@ -449,10 +449,10 @@ exports[`diff 4`] = ` "actual": "Object { "hello": "world", }", - "diff": "- Expected: + "diff": "- Expected: undefined -+ Received: ++ Received: { "hello": "world", }", @@ -466,10 +466,10 @@ exports[`diff 5`] = ` "actual": "Object { "hello": "world", }", - "diff": "- Expected: + "diff": "- Expected: null -+ Received: ++ Received: { "hello": "world", }", @@ -747,7 +747,7 @@ exports[`toBeOneOf() > error message 3`] = ` "actual": "Object { "a": 0, }", - "diff": "- Expected: + "diff": "- Expected: toBeOneOf -+ Received: ++ Received: { "a": 0, }", @@ -851,10 +851,10 @@ Received: "hellohellohellohellohellohellohellohellohellohellohellohellohellohell exports[`toMatch/toContain diff 3`] = ` { "actual": "hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello", - "diff": "- Expected: + "diff": "- Expected: /world/ -+ Received: ++ Received: "hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello"", "expected": "/world/", "message": "expected 'hellohellohellohellohellohellohellohe…' to match /world/", diff --git a/test/core/test/expect.test.ts b/test/core/test/expect.test.ts index 998a7e5ec40c..f7db869cd890 100644 --- a/test/core/test/expect.test.ts +++ b/test/core/test/expect.test.ts @@ -535,7 +535,7 @@ describe('Standard Schema', () => { const error = processError(err) const diff = stripVTControlCharacters(error.diff!) expect(diff).toMatchInlineSnapshot(` - "- Expected: + "- Expected: SchemaMatching { "issues": [ { @@ -544,7 +544,7 @@ describe('Standard Schema', () => { ], } - + Received: + + Received: 123" `) } @@ -673,10 +673,10 @@ describe('Standard Schema', () => { const error = processError(err) const diff = stripVTControlCharacters(error.diff!) expect(diff).toMatchInlineSnapshot(` - "- Expected: + "- Expected: SchemaMatching - + Received: + + Received: "hello"" `) } From 04bff40b0ec299a8a5bcb3c03e327082491ee0d8 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Tue, 17 Feb 2026 13:39:32 +0900 Subject: [PATCH 3/4] fix: more --- packages/expect/src/jest-expect.ts | 4 ++-- test/core/test/__snapshots__/mocked.test.ts.snap | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/expect/src/jest-expect.ts b/packages/expect/src/jest-expect.ts index dad17d6d31d7..92c1dfb146ea 100644 --- a/packages/expect/src/jest-expect.ts +++ b/packages/expect/src/jest-expect.ts @@ -1227,7 +1227,7 @@ function ordinalOf(i: number) { function formatCalls(spy: MockInstance, msg: string, showActualCall?: any) { if (spy.mock.calls.length) { msg += c.gray( - `\n\nReceived: \n\n${spy.mock.calls + `\n\nReceived:\n\n${spy.mock.calls .map((callArg, i) => { let methodCall = c.bold( ` ${ordinalOf(i + 1)} ${spy.getMockName()} call:\n\n`, @@ -1264,7 +1264,7 @@ function formatReturns( ) { if (results.length) { msg += c.gray( - `\n\nReceived: \n\n${results + `\n\nReceived:\n\n${results .map((callReturn, i) => { let methodCall = c.bold( ` ${ordinalOf(i + 1)} ${spy.getMockName()} call return:\n\n`, diff --git a/test/core/test/__snapshots__/mocked.test.ts.snap b/test/core/test/__snapshots__/mocked.test.ts.snap index 808a273cd11a..31a7826e1ee0 100644 --- a/test/core/test/__snapshots__/mocked.test.ts.snap +++ b/test/core/test/__snapshots__/mocked.test.ts.snap @@ -3,7 +3,7 @@ exports[`mocked function which fails on toReturnWith > just one call 1`] = ` "expected "vi.fn()" to return with: 2 at least once -Received: +Received: 1st vi.fn() call return: @@ -18,7 +18,7 @@ Number of calls: 1 exports[`mocked function which fails on toReturnWith > multi calls 1`] = ` "expected "vi.fn()" to return with: 2 at least once -Received: +Received: 1st vi.fn() call return: @@ -43,7 +43,7 @@ Number of calls: 3 exports[`mocked function which fails on toReturnWith > oject type 1`] = ` "expected "vi.fn()" to return with: { a: '4' } at least once -Received: +Received: 1st vi.fn() call return: From 9e69a53c5e6240a39b0b0cc8f5e657976e0fe0f0 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 20 Feb 2026 14:49:01 +0900 Subject: [PATCH 4/4] test: update --- test/cli/test/stacktraces.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/cli/test/stacktraces.test.ts b/test/cli/test/stacktraces.test.ts index c2817e28ac56..4bdcd83960c2 100644 --- a/test/cli/test/stacktraces.test.ts +++ b/test/cli/test/stacktraces.test.ts @@ -264,12 +264,12 @@ it('resolves/rejects', async () => { FAIL repro.test.ts > rejects: resolves when rejection expected AssertionError: promise resolved "3" instead of rejecting - - Expected: + - Expected: Error { "message": "rejected promise", } - + Received: + + Received: 3 ❯ repro.test.ts:13:41 @@ -343,12 +343,12 @@ it('resolves/rejects', async () => { FAIL repro.test.ts > rejects: resolves when rejection expected AssertionError: promise resolved "3" instead of rejecting - - Expected: + - Expected: Error { "message": "rejected promise", } - + Received: + + Received: 3 ❯ repro.test.ts:13:40