Skip to content

Commit

Permalink
Pick adaf5eb fixes ##133
Browse files Browse the repository at this point in the history
  • Loading branch information
hurali97 committed Apr 3, 2024
1 parent 87b14b4 commit 631c013
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions Libraries/LogBox/Data/__tests__/parseLogBoxLog-test.js
Expand Up @@ -1012,6 +1012,54 @@ Please follow the instructions at: fburl.com/rn-remote-assets`,
});
});

it('detects a component stack for ts, tsx, jsx, and js files', () => {
expect(
parseLogBoxLog([
'Some kind of message\n in MyTSComponent (at MyTSXComponent.ts:1)\n in MyTSXComponent (at MyTSCComponent.tsx:1)\n in MyJSXComponent (at MyJSXComponent.jsx:1)\n in MyJSComponent (at MyJSComponent.js:1)',
]),
).toEqual({
componentStack: [
{
content: 'MyTSComponent',
fileName: 'MyTSXComponent.ts',
location: {
column: -1,
row: 1,
},
},
{
content: 'MyTSXComponent',
fileName: 'MyTSCComponent.tsx',
location: {
column: -1,
row: 1,
},
},
{
content: 'MyJSXComponent',
fileName: 'MyJSXComponent.jsx',
location: {
column: -1,
row: 1,
},
},
{
content: 'MyJSComponent',
fileName: 'MyJSComponent.js',
location: {
column: -1,
row: 1,
},
},
],
category: 'Some kind of message',
message: {
content: 'Some kind of message',
substitutions: [],
},
});
});

it('detects a component stack in the first argument (JSC)', () => {
expect(
parseLogBoxLog([
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LogBox/Data/parseLogBoxLog.js
Expand Up @@ -192,7 +192,7 @@ export function parseComponentStack(message: string): ComponentStack {
if (!s) {
return null;
}
const match = s.match(/(.*) \(at (.*\.js):([\d]+)\)/);
const match = s.match(/(.*) \(at (.*\.(?:js|jsx|ts|tsx)):([\d]+)\)/);
if (!match) {
return null;
}
Expand Down

0 comments on commit 631c013

Please sign in to comment.