Skip to content

Commit 395d1a2

Browse files
fix: remove trailing spaces from diff error log (#9680)
Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
1 parent 50727a0 commit 395d1a2

File tree

7 files changed

+52
-52
lines changed

7 files changed

+52
-52
lines changed

packages/expect/src/jest-expect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,7 +1235,7 @@ function ordinalOf(i: number) {
12351235
function formatCalls(spy: MockInstance, msg: string, showActualCall?: any) {
12361236
if (spy.mock.calls.length) {
12371237
msg += c.gray(
1238-
`\n\nReceived: \n\n${spy.mock.calls
1238+
`\n\nReceived:\n\n${spy.mock.calls
12391239
.map((callArg, i) => {
12401240
let methodCall = c.bold(
12411241
` ${ordinalOf(i + 1)} ${spy.getMockName()} call:\n\n`,
@@ -1272,7 +1272,7 @@ function formatReturns(
12721272
) {
12731273
if (results.length) {
12741274
msg += c.gray(
1275-
`\n\nReceived: \n\n${results
1275+
`\n\nReceived:\n\n${results
12761276
.map((callReturn, i) => {
12771277
let methodCall = c.bold(
12781278
` ${ordinalOf(i + 1)} ${spy.getMockName()} call return:\n\n`,

packages/ui/client/components/views/ViewReport.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const textStacks = Array.from({ length: 5 }, makeTextStack)
2727
const diff = `
2828
\x1B[32m- Expected\x1B[39m
2929
\x1B[31m+ Received\x1B[39m
30-
30+
3131
\x1B[2m Object {\x1B[22m
3232
\x1B[2m "a": 1,\x1B[22m
3333
\x1B[32m- "b": 2,\x1B[39m

packages/utils/src/diff/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ export function diff(a: any, b: any, options?: DiffOptions): string | undefined
110110
}
111111
aDisplay = truncate(aDisplay)
112112
bDisplay = truncate(bDisplay)
113-
const aDiff = `${aColor(`${aIndicator} ${aAnnotation}:`)} \n${aDisplay}`
114-
const bDiff = `${bColor(`${bIndicator} ${bAnnotation}:`)} \n${bDisplay}`
113+
const aDiff = `${aColor(`${aIndicator} ${aAnnotation}:`)}\n${aDisplay}`
114+
const bDiff = `${bColor(`${bIndicator} ${bAnnotation}:`)}\n${bDisplay}`
115115
return `${aDiff}\n\n${bDiff}`
116116
}
117117

test/cli/test/stacktraces.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,12 @@ it('resolves/rejects', async () => {
264264
FAIL repro.test.ts > rejects: resolves when rejection expected
265265
AssertionError: promise resolved "3" instead of rejecting
266266
267-
- Expected:
267+
- Expected:
268268
Error {
269269
"message": "rejected promise",
270270
}
271271
272-
+ Received:
272+
+ Received:
273273
3
274274
275275
❯ repro.test.ts:13:41
@@ -343,12 +343,12 @@ it('resolves/rejects', async () => {
343343
FAIL repro.test.ts > rejects: resolves when rejection expected
344344
AssertionError: promise resolved "3" instead of rejecting
345345
346-
- Expected:
346+
- Expected:
347347
Error {
348348
"message": "rejected promise",
349349
}
350350
351-
+ Received:
351+
+ Received:
352352
3
353353
354354
❯ repro.test.ts:13:40

test/core/test/__snapshots__/jest-expect.test.ts.snap

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ exports[`asymmetric matcher error 4`] = `
5959
exports[`asymmetric matcher error 5`] = `
6060
{
6161
"actual": "hello",
62-
"diff": "- Expected:
62+
"diff": "- Expected:
6363
stringContainingCustom<"xx">
6464
65-
+ Received:
65+
+ Received:
6666
"hello"",
6767
"expected": "stringContainingCustom<"xx">",
6868
"message": "expected 'hello' to deeply equal stringContainingCustom<"xx">",
@@ -72,10 +72,10 @@ stringContainingCustom<"xx">
7272
exports[`asymmetric matcher error 6`] = `
7373
{
7474
"actual": "hello",
75-
"diff": "- Expected:
75+
"diff": "- Expected:
7676
not.stringContainingCustom<"ll">
7777
78-
+ Received:
78+
+ Received:
7979
"hello"",
8080
"expected": "not.stringContainingCustom<"ll">",
8181
"message": "expected 'hello' to deeply equal not.stringContainingCustom<"ll">",
@@ -141,12 +141,12 @@ exports[`asymmetric matcher error 10`] = `
141141
exports[`asymmetric matcher error 11`] = `
142142
{
143143
"actual": "hello",
144-
"diff": "- Expected:
144+
"diff": "- Expected:
145145
testComplexMatcher<Object {
146146
"x": "y",
147147
}>
148148
149-
+ Received:
149+
+ Received:
150150
"hello"",
151151
"expected": "testComplexMatcher<Object {
152152
"x": "y",
@@ -226,13 +226,13 @@ exports[`asymmetric matcher error 15`] = `
226226
exports[`asymmetric matcher error 16`] = `
227227
{
228228
"actual": "foo",
229-
"diff": "- Expected:
229+
"diff": "- Expected:
230230
toBeOneOf<Array [
231231
"bar",
232232
"baz",
233233
]>
234234
235-
+ Received:
235+
+ Received:
236236
"foo"",
237237
"expected": "toBeOneOf<Array [
238238
"bar",
@@ -248,14 +248,14 @@ toBeOneOf<Array [
248248
exports[`asymmetric matcher error 17`] = `
249249
{
250250
"actual": "0",
251-
"diff": "- Expected:
251+
"diff": "- Expected:
252252
toBeOneOf<Array [
253253
Any<String>,
254254
null,
255255
undefined,
256256
]>
257257
258-
+ Received:
258+
+ Received:
259259
0",
260260
"expected": "toBeOneOf<Array [
261261
Any<String>,
@@ -272,7 +272,7 @@ exports[`asymmetric matcher error 18`] = `
272272
"k": "v",
273273
"k2": "v2",
274274
}",
275-
"diff": "- Expected:
275+
"diff": "- Expected:
276276
toBeOneOf<Array [
277277
ObjectContaining {
278278
"k": "v",
@@ -282,7 +282,7 @@ toBeOneOf<Array [
282282
undefined,
283283
]>
284284
285-
+ Received:
285+
+ Received:
286286
{
287287
"k": "v",
288288
"k2": "v2",
@@ -320,10 +320,10 @@ exports[`asymmetric matcher error 20`] = `
320320
exports[`asymmetric matcher error 21`] = `
321321
{
322322
"actual": "hello",
323-
"diff": "- Expected:
323+
"diff": "- Expected:
324324
stringContainingCustom<"xx">
325325
326-
+ Received:
326+
+ Received:
327327
"hello"",
328328
"expected": "stringContainingCustom<"xx">",
329329
"message": "expected error to match asymmetric matcher",
@@ -342,10 +342,10 @@ exports[`asymmetric matcher error 22`] = `
342342
exports[`asymmetric matcher error 23`] = `
343343
{
344344
"actual": "hello",
345-
"diff": "- Expected:
345+
"diff": "- Expected:
346346
stringContainingCustom<"ll">
347347
348-
+ Received:
348+
+ Received:
349349
"hello"",
350350
"expected": "stringContainingCustom<"ll">",
351351
"message": "expected error not to match asymmetric matcher",
@@ -355,10 +355,10 @@ stringContainingCustom<"ll">
355355
exports[`asymmetric matcher error 24`] = `
356356
{
357357
"actual": "[Error: hello]",
358-
"diff": "- Expected:
358+
"diff": "- Expected:
359359
StringContaining "ll"
360360
361-
+ Received:
361+
+ Received:
362362
Error {
363363
"message": "hello",
364364
}",
@@ -370,10 +370,10 @@ Error {
370370
exports[`asymmetric matcher error 25`] = `
371371
{
372372
"actual": "[Error: hello]",
373-
"diff": "- Expected:
373+
"diff": "- Expected:
374374
stringContainingCustom<"ll">
375375
376-
+ Received:
376+
+ Received:
377377
Error {
378378
"message": "hello",
379379
}",
@@ -385,10 +385,10 @@ Error {
385385
exports[`asymmetric matcher error 26`] = `
386386
{
387387
"actual": "[Error: hello]",
388-
"diff": "- Expected:
388+
"diff": "- Expected:
389389
[Function MyError1]
390390
391-
+ Received:
391+
+ Received:
392392
MyError2 {
393393
"message": "hello",
394394
}",
@@ -400,10 +400,10 @@ MyError2 {
400400
exports[`diff 1`] = `
401401
{
402402
"actual": "undefined",
403-
"diff": "- Expected:
403+
"diff": "- Expected:
404404
true
405405
406-
+ Received:
406+
+ Received:
407407
undefined",
408408
"expected": "true",
409409
"message": "expected undefined to be truthy",
@@ -415,10 +415,10 @@ exports[`diff 2`] = `
415415
"actual": "Object {
416416
"hello": "world",
417417
}",
418-
"diff": "- Expected:
418+
"diff": "- Expected:
419419
false
420420
421-
+ Received:
421+
+ Received:
422422
{
423423
"hello": "world",
424424
}",
@@ -432,10 +432,10 @@ exports[`diff 3`] = `
432432
"actual": "Object {
433433
"hello": "world",
434434
}",
435-
"diff": "- Expected:
435+
"diff": "- Expected:
436436
NaN
437437
438-
+ Received:
438+
+ Received:
439439
{
440440
"hello": "world",
441441
}",
@@ -449,10 +449,10 @@ exports[`diff 4`] = `
449449
"actual": "Object {
450450
"hello": "world",
451451
}",
452-
"diff": "- Expected:
452+
"diff": "- Expected:
453453
undefined
454454
455-
+ Received:
455+
+ Received:
456456
{
457457
"hello": "world",
458458
}",
@@ -466,10 +466,10 @@ exports[`diff 5`] = `
466466
"actual": "Object {
467467
"hello": "world",
468468
}",
469-
"diff": "- Expected:
469+
"diff": "- Expected:
470470
null
471471
472-
+ Received:
472+
+ Received:
473473
{
474474
"hello": "world",
475475
}",
@@ -747,7 +747,7 @@ exports[`toBeOneOf() > error message 3`] = `
747747
"actual": "Object {
748748
"a": 0,
749749
}",
750-
"diff": "- Expected:
750+
"diff": "- Expected:
751751
toBeOneOf<Array [
752752
ObjectContaining {
753753
"b": 0,
@@ -756,7 +756,7 @@ toBeOneOf<Array [
756756
undefined,
757757
]>
758758
759-
+ Received:
759+
+ Received:
760760
{
761761
"a": 0,
762762
}",
@@ -851,10 +851,10 @@ Received: "hellohellohellohellohellohellohellohellohellohellohellohellohellohell
851851
exports[`toMatch/toContain diff 3`] = `
852852
{
853853
"actual": "hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello",
854-
"diff": "- Expected:
854+
"diff": "- Expected:
855855
/world/
856856
857-
+ Received:
857+
+ Received:
858858
"hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello"",
859859
"expected": "/world/",
860860
"message": "expected 'hellohellohellohellohellohellohellohe…' to match /world/",

test/core/test/__snapshots__/mocked.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`mocked function which fails on toReturnWith > just one call 1`] = `
44
"expected "vi.fn()" to return with: 2 at least once
55
6-
Received:
6+
Received:
77
88
1st vi.fn() call return:
99
@@ -18,7 +18,7 @@ Number of calls: 1
1818
exports[`mocked function which fails on toReturnWith > multi calls 1`] = `
1919
"expected "vi.fn()" to return with: 2 at least once
2020
21-
Received:
21+
Received:
2222
2323
1st vi.fn() call return:
2424
@@ -43,7 +43,7 @@ Number of calls: 3
4343
exports[`mocked function which fails on toReturnWith > oject type 1`] = `
4444
"expected "vi.fn()" to return with: { a: '4' } at least once
4545
46-
Received:
46+
Received:
4747
4848
1st vi.fn() call return:
4949

test/core/test/expect.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ describe('Standard Schema', () => {
535535
const error = processError(err)
536536
const diff = stripVTControlCharacters(error.diff!)
537537
expect(diff).toMatchInlineSnapshot(`
538-
"- Expected:
538+
"- Expected:
539539
SchemaMatching {
540540
"issues": [
541541
{
@@ -544,7 +544,7 @@ describe('Standard Schema', () => {
544544
],
545545
}
546546
547-
+ Received:
547+
+ Received:
548548
123"
549549
`)
550550
}
@@ -673,10 +673,10 @@ describe('Standard Schema', () => {
673673
const error = processError(err)
674674
const diff = stripVTControlCharacters(error.diff!)
675675
expect(diff).toMatchInlineSnapshot(`
676-
"- Expected:
676+
"- Expected:
677677
SchemaMatching
678678
679-
+ Received:
679+
+ Received:
680680
"hello""
681681
`)
682682
}

0 commit comments

Comments
 (0)