Skip to content

Commit

Permalink
console preview for Error objects (#46010)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #46010

X-link: facebook/hermes#1474

Changelog:
[General][Added]: support for rendering Error object previews in Chrome DevTools console

On web, an array of Error objects have previews. This diff brings the parity to RN DevTools

Reviewed By: huntie

Differential Revision: D61243518

fbshipit-source-id: d9c6af4b44cef44cb63c4462eee649a8e498a429
  • Loading branch information
EdmondChuiHW authored and facebook-github-bot committed Aug 16, 2024
1 parent 1740a56 commit cae9ae5
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,35 @@ TEST_P(ConsoleApiTest, testConsoleLogWithErrorObject) {
})())");
}

TEST_P(ConsoleApiTest, testConsoleLogWithArrayOfErrors) {
InSequence s;
expectConsoleApiCallImmediate(AllOf(
AtJsonPtr("/type", "log"),
AtJsonPtr("/args/0/type", "object"),
AtJsonPtr("/args/0/subtype", "array"),
AtJsonPtr("/args/0/description", "Array(2)"),
AtJsonPtr("/args/0/preview/description", "Array(2)"),
AtJsonPtr("/args/0/preview/type", "object"),
AtJsonPtr("/args/0/preview/subtype", "array"),
AtJsonPtr("/args/0/preview/properties/0/type", "object"),
AtJsonPtr("/args/0/preview/properties/0/subtype", "error"),
AtJsonPtr(
"/args/0/preview/properties/0/value",
"Error: wut\n"
" at typicallyUrlsAreLongAndWillHitTheAbbreviationLimit (<eval>:6:29)\n"
" at reallyLon…")));
expectConsoleApiCallBuffered(AllOf(AtJsonPtr("/type", "log")));
eval(R"((() => {
function reallyLongFunctionNameToAssertMaxLengthOfAbbreviatedString() {
typicallyUrlsAreLongAndWillHitTheAbbreviationLimit();
}
function typicallyUrlsAreLongAndWillHitTheAbbreviationLimit() {
console.log([new Error('wut'), new TypeError('why')]);
}
reallyLongFunctionNameToAssertMaxLengthOfAbbreviatedString();
})())");
}

TEST_P(ConsoleApiTest, testConsoleWarn) {
InSequence s;
expectConsoleApiCall(AllOf(
Expand Down

0 comments on commit cae9ae5

Please sign in to comment.