diff options
author | Hajime-san <41257923+Hajime-san@users.noreply.github.com> | 2024-08-20 10:27:36 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-20 01:27:36 +0000 |
commit | 19bcb40059f6ba730b6d05d8edf005c6b40f6ff8 (patch) | |
tree | e7c60d8957a8609199a3dad24455518cc36fac32 /cli/tools/test/fmt.rs | |
parent | 4f49f703c10afcde7155baac2b494fa6670c0115 (diff) |
feat(cli/tools): add a subcommand `--hide-stacktraces` for test (#24095)
Diffstat (limited to 'cli/tools/test/fmt.rs')
-rw-r--r-- | cli/tools/test/fmt.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cli/tools/test/fmt.rs b/cli/tools/test/fmt.rs index d66c72239..174155072 100644 --- a/cli/tools/test/fmt.rs +++ b/cli/tools/test/fmt.rs @@ -72,16 +72,24 @@ fn abbreviate_test_error(js_error: &JsError) -> JsError { // This function prettifies `JsError` and applies some changes specifically for // test runner purposes: // +// - hide stack traces if `options.hide_stacktraces` is set to `true` +// // - filter out stack frames: // - if stack trace consists of mixed user and internal code, the frames // below the first user code frame are filtered out // - if stack trace consists only of internal code it is preserved as is -pub fn format_test_error(js_error: &JsError) -> String { +pub fn format_test_error( + js_error: &JsError, + options: &TestFailureFormatOptions, +) -> String { let mut js_error = abbreviate_test_error(js_error); js_error.exception_message = js_error .exception_message .trim_start_matches("Uncaught ") .to_string(); + if options.hide_stacktraces { + return js_error.exception_message; + } format_js_error(&js_error) } |