| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ecb963d commit 1ee7ce6
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -429,11 +429,37 @@ class AssertionError extends Error { | |||
| 429 | 429 | } | |
| 430 | 430 | ||
| 431 | 431 | [inspect.custom](recurseTimes, ctx) { | |
| 432 | + // Long strings should not be fully inspected. | ||
| 433 | + const tmpActual = this.actual; | ||
| 434 | + const tmpExpected = this.expected; | ||
| 435 | + | ||
| 436 | + for (const name of ['actual', 'expected']) { | ||
| 437 | + if (typeof this[name] === 'string') { | ||
| 438 | + const lines = this[name].split('\n'); | ||
| 439 | + if (lines.length > 10) { | ||
| 440 | + lines.length = 10; | ||
| 441 | + this[name] = `${lines.join('\n')}\n...`; | ||
| 442 | + } else if (this[name].length > 512) { | ||
| 443 | + this[name] = `${this[name].slice(512)}...`; | ||
| 444 | + } | ||
| 445 | + } | ||
| 446 | + } | ||
| 447 | + | ||
| 432 | 448 | // This limits the `actual` and `expected` property default inspection to | |
| 433 | 449 | // the minimum depth. Otherwise those values would be too verbose compared | |
| 434 | 450 | // to the actual error message which contains a combined view of these two | |
| 435 | 451 | // input values. | |
| 436 | - return inspect(this, { ...ctx, customInspect: false, depth: 0 }); | ||
| 452 | + const result = inspect(this, { | ||
| 453 | + ...ctx, | ||
| 454 | + customInspect: false, | ||
| 455 | + depth: 0 | ||
| 456 | + }); | ||
| 457 | + | ||
| 458 | + // Reset the properties after inspection. | ||
| 459 | + this.actual = tmpActual; | ||
| 460 | + this.expected = tmpExpected; | ||
| 461 | + | ||
| 462 | + return result; | ||
| 437 | 463 | } | |
| 438 | 464 | } | |
| 439 | 465 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments