From 5f2d9a4a220307b1111c91dfac74951ef3925457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sat, 16 Apr 2022 19:51:12 +0200 Subject: feat(test): use structured data for JavaScript errors in tests (#14287) This commit rewrites test runner to send structured error data from JavaScript to Rust instead of passing strings. This will allow to customize display of errors in test report (which will be addressed in follow up commits). --- runtime/js/40_testing.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'runtime/js') diff --git a/runtime/js/40_testing.js b/runtime/js/40_testing.js index fdd044503..c5adc1f59 100644 --- a/runtime/js/40_testing.js +++ b/runtime/js/40_testing.js @@ -804,7 +804,7 @@ await test.fn(step); const failCount = step.failedChildStepsCount(); return failCount === 0 ? "ok" : { - "failed": formatError( + "failed": core.destructureError( new Error( `${failCount} test step${failCount === 1 ? "" : "s"} failed.`, ), @@ -812,7 +812,7 @@ }; } catch (error) { return { - "failed": formatError(error), + "failed": core.destructureError(error), }; } finally { step.finalized = true; @@ -1211,11 +1211,11 @@ return "ignored"; case "pending": return { - "pending": this.error && formatError(this.error), + "pending": this.error && core.destructureError(this.error), }; case "failed": return { - "failed": this.error && formatError(this.error), + "failed": this.error && core.destructureError(this.error), }; default: throw new Error(`Unhandled status: ${this.status}`); @@ -1335,7 +1335,7 @@ subStep.status = "ok"; } } catch (error) { - subStep.error = formatError(error); + subStep.error = error; subStep.status = "failed"; } -- cgit v1.2.3