diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-10-01 03:54:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 21:54:56 +0200 |
commit | 6bf5c850e6b4f6163721bd673b191bda0e0dc0a6 (patch) | |
tree | f02e9d3afb10709467531175b4841fb170ac282d /runtime/js | |
parent | c3e441c5b54de09ca3af3e1fd0098e8d307c18d7 (diff) |
fix(runtime/testing): format aggregate errors (#12183)
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/40_testing.js | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js index 38382f9fd..f4f5373c6 100644 --- a/runtime/js/40_testing.js +++ b/runtime/js/40_testing.js @@ -186,6 +186,23 @@ finishing test case.`; ArrayPrototypePush(tests, testDef); } + function formatFailure(error) { + if (error.errors) { + const message = error + .errors + .map((error) => + inspectArgs([error]).replace(/^(?!\s*$)/gm, " ".repeat(4)) + ) + .join("\n"); + + return { + failed: error.name + "\n" + message + error.stack, + }; + } + + return { failed: inspectArgs([error]) }; + } + function createTestFilter(filter) { return (def) => { if (filter) { @@ -213,10 +230,11 @@ finishing test case.`; try { await fn(); - return "ok"; } catch (error) { - return { "failed": inspectArgs([error]) }; + return formatFailure(error); } + + return "ok"; } function getTestOrigin() { |