| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5700cd1 commit 97c52ca
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -620,8 +620,13 @@ function expectedException(actual, expected, message, fn) { | |||
| 620 | 620 | generatedMessage = true; | |
| 621 | 621 | message = 'The error is expected to be an instance of ' + | |
| 622 | 622 | `"${expected.name}". Received `; | |
| 623 | + // TODO: Special handle identical names. | ||
| 623 | 624 | if (isError(actual)) { | |
| 624 | - message += `"${actual.name}"`; | ||
| 625 | + const name = actual.constructor && actual.constructor.name; | ||
| 626 | + message += `"${name || actual.name}"`; | ||
| 627 | + if (actual.message) { | ||
| 628 | + message += `\n\nError message:\n\n${actual.message}`; | ||
| 629 | + } | ||
| 625 | 630 | } else { | |
| 626 | 631 | message += `"${inspect(actual, { depth: -1 })}"`; | |
| 627 | 632 | } | |
@@ -636,6 +641,10 @@ function expectedException(actual, expected, message, fn) { | |||
| 636 | 641 | const name = expected.name ? `"${expected.name}" ` : ''; | |
| 637 | 642 | message = `The ${name}validation function is expected to return` + | |
| 638 | 643 | ` "true". Received ${inspect(res)}`; | |
| 644 | + | ||
| 645 | + if (isError(actual)) { | ||
| 646 | + message += `\n\nCaught error:\n\n${actual}`; | ||
| 647 | + } | ||
| 639 | 648 | } | |
| 640 | 649 | throwError = true; | |
| 641 | 650 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -73,7 +73,8 @@ const invalidThenableFunc = () => { | |||
| 73 | 73 | () => assert.rejects(Promise.reject(err), validate), | |
| 74 | 74 | { | |
| 75 | 75 | message: 'The "validate" validation function is expected to ' + | |
| 76 | - "return \"true\". Received 'baz'", | ||
| 76 | + "return \"true\". Received 'baz'\n\nCaught error:\n\n" + | ||
| 77 | + 'Error: foobar', | ||
| 77 | 78 | code: 'ERR_ASSERTION', | |
| 78 | 79 | actual: err, | |
| 79 | 80 | expected: validate, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,7 +133,7 @@ assert.throws( | |||
| 133 | 133 | name: 'AssertionError', | |
| 134 | 134 | operator: 'throws', | |
| 135 | 135 | message: 'The error is expected to be an instance of "AssertionError". ' + | |
| 136 | - 'Received "TypeError"' | ||
| 136 | + 'Received "TypeError"\n\nError message:\n\n[object Object]' | ||
| 137 | 137 | } | |
| 138 | 138 | ); | |
| 139 | 139 | ||
@@ -255,7 +255,7 @@ a.throws(() => thrower(TypeError), (err) => { | |||
| 255 | 255 | assert.strictEqual( | |
| 256 | 256 | err.message, | |
| 257 | 257 | 'The error is expected to be an instance of "ES6Error". ' + | |
| 258 | - 'Received "Error"' | ||
| 258 | + 'Received "AnotherErrorType"\n\nError message:\n\nfoo' | ||
| 259 | 259 | ); | |
| 260 | 260 | assert.strictEqual(err.actual, actual); | |
| 261 | 261 | return true; | |
@@ -1334,7 +1334,8 @@ assert.throws( | |||
| 1334 | 1334 | () => assert.throws(() => { throw err; }, validate), | |
| 1335 | 1335 | { | |
| 1336 | 1336 | message: 'The validation function is expected to ' + | |
| 1337 | - `return "true". Received ${inspect(validate())}`, | ||
| 1337 | + `return "true". Received ${inspect(validate())}\n\nCaught ` + | ||
| 1338 | + `error:\n\n${err}`, | ||
| 1338 | 1339 | code: 'ERR_ASSERTION', | |
| 1339 | 1340 | actual: err, | |
| 1340 | 1341 | expected: validate, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments