diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-04-16 19:51:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-16 19:51:12 +0200 |
commit | 5f2d9a4a220307b1111c91dfac74951ef3925457 (patch) | |
tree | 0873546419f8f8dd9ccbaf53dd0c6aa04c78baf0 /cli/lsp/testing/execution.rs | |
parent | 32aaefd9eeea4a08eec0159f6374bfadf2bec62f (diff) |
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).
Diffstat (limited to 'cli/lsp/testing/execution.rs')
-rw-r--r-- | cli/lsp/testing/execution.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/cli/lsp/testing/execution.rs b/cli/lsp/testing/execution.rs index bc780a475..b305b1650 100644 --- a/cli/lsp/testing/execution.rs +++ b/cli/lsp/testing/execution.rs @@ -8,6 +8,7 @@ use crate::checksum; use crate::create_main_worker; use crate::emit; use crate::flags; +use crate::fmt_errors::PrettyJsError; use crate::located_script_name; use crate::lsp::client::Client; use crate::lsp::client::TestingNotification; @@ -797,10 +798,14 @@ impl test::TestReporter for LspTestReporter { test: desc.into(), }) } - test::TestResult::Failed(message) => { + test::TestResult::Failed(js_error) => { + let err_string = PrettyJsError::create(*js_error.clone()) + .to_string() + .trim_start_matches("Uncaught ") + .to_string(); self.progress(lsp_custom::TestRunProgressMessage::Failed { test: desc.into(), - messages: as_test_messages(message, false), + messages: as_test_messages(err_string, false), duration: Some(elapsed as u32), }) } @@ -839,9 +844,13 @@ impl test::TestReporter for LspTestReporter { test: desc.into(), }) } - test::TestStepResult::Failed(message) => { - let messages = if let Some(message) = message { - as_test_messages(message, false) + test::TestStepResult::Failed(js_error) => { + let messages = if let Some(js_error) = js_error { + let err_string = PrettyJsError::create(*js_error.clone()) + .to_string() + .trim_start_matches("Uncaught ") + .to_string(); + as_test_messages(err_string, false) } else { vec![] }; |