feat(cli/tools): add a subcommand --hide-stacktraces for test (#24095)

This commit is contained in:
Hajime-san 2024-08-20 10:27:36 +09:00 committed by GitHub
parent 4f49f703c1
commit 19bcb40059
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 300 additions and 58 deletions

View file

@ -15,6 +15,7 @@ use crate::lsp::logging::lsp_log;
use crate::tools::test;
use crate::tools::test::create_test_event_channel;
use crate::tools::test::FailFastTracker;
use crate::tools::test::TestFailureFormatOptions;
use deno_core::anyhow::anyhow;
use deno_core::error::AnyError;
@ -655,7 +656,10 @@ impl LspTestReporter {
let desc = self.tests.get(&desc.id).unwrap();
self.progress(lsp_custom::TestRunProgressMessage::Failed {
test: desc.as_test_identifier(&self.tests),
messages: as_test_messages(failure.to_string(), false),
messages: as_test_messages(
failure.format(&TestFailureFormatOptions::default()),
false,
),
duration: Some(elapsed as u32),
})
}
@ -675,7 +679,7 @@ impl LspTestReporter {
let err_string = format!(
"Uncaught error from {}: {}\nThis error was not caught from a test and caused the test runner to fail on the referenced module.\nIt most likely originated from a dangling promise, event/timeout handler or top-level code.",
origin,
test::fmt::format_test_error(js_error)
test::fmt::format_test_error(js_error, &TestFailureFormatOptions::default())
);
let messages = as_test_messages(err_string, false);
for desc in self.tests.values().filter(|d| d.origin() == origin) {
@ -751,7 +755,10 @@ impl LspTestReporter {
test::TestStepResult::Failed(failure) => {
self.progress(lsp_custom::TestRunProgressMessage::Failed {
test: desc.as_test_identifier(&self.tests),
messages: as_test_messages(failure.to_string(), false),
messages: as_test_messages(
failure.format(&TestFailureFormatOptions::default()),
false,
),
duration: Some(elapsed as u32),
})
}