Skip to content

Commit 631c013

Browse files
committed
Pick adaf5eb fixes ##133
1 parent 87b14b4 commit 631c013

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

Libraries/LogBox/Data/__tests__/parseLogBoxLog-test.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,54 @@ Please follow the instructions at: fburl.com/rn-remote-assets`,
10121012
});
10131013
});
10141014

1015+
it('detects a component stack for ts, tsx, jsx, and js files', () => {
1016+
expect(
1017+
parseLogBoxLog([
1018+
'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)',
1019+
]),
1020+
).toEqual({
1021+
componentStack: [
1022+
{
1023+
content: 'MyTSComponent',
1024+
fileName: 'MyTSXComponent.ts',
1025+
location: {
1026+
column: -1,
1027+
row: 1,
1028+
},
1029+
},
1030+
{
1031+
content: 'MyTSXComponent',
1032+
fileName: 'MyTSCComponent.tsx',
1033+
location: {
1034+
column: -1,
1035+
row: 1,
1036+
},
1037+
},
1038+
{
1039+
content: 'MyJSXComponent',
1040+
fileName: 'MyJSXComponent.jsx',
1041+
location: {
1042+
column: -1,
1043+
row: 1,
1044+
},
1045+
},
1046+
{
1047+
content: 'MyJSComponent',
1048+
fileName: 'MyJSComponent.js',
1049+
location: {
1050+
column: -1,
1051+
row: 1,
1052+
},
1053+
},
1054+
],
1055+
category: 'Some kind of message',
1056+
message: {
1057+
content: 'Some kind of message',
1058+
substitutions: [],
1059+
},
1060+
});
1061+
});
1062+
10151063
it('detects a component stack in the first argument (JSC)', () => {
10161064
expect(
10171065
parseLogBoxLog([

Libraries/LogBox/Data/parseLogBoxLog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export function parseComponentStack(message: string): ComponentStack {
192192
if (!s) {
193193
return null;
194194
}
195-
const match = s.match(/(.*) \(at (.*\.js):([\d]+)\)/);
195+
const match = s.match(/(.*) \(at (.*\.(?:js|jsx|ts|tsx)):([\d]+)\)/);
196196
if (!match) {
197197
return null;
198198
}

0 commit comments

Comments
 (0)