summaryrefslogtreecommitdiff
path: root/runtime/js
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/js')
-rw-r--r--runtime/js/40_testing.js22
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() {