File tree Expand file tree Collapse file tree 3 files changed +87
-0
lines changed
packages/browser/test/unit/tracekit Expand file tree Collapse file tree 3 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { exceptionFromError } from '../../../src/eventbuilder' ;
2
2
import { defaultStackParser as parser } from '../../../src/stack-parsers' ;
3
3
4
+ const a =
5
+ 'Error\n' +
6
+ ' at onClick (http://localhost:3002/(group)/script.js:1:644)\n' +
7
+ ' at a (http://localhost:3002/[param]/script.js:1:644)\n' +
8
+ ' at b (http://localhost:3002/[param]/(group)/script.js:1:644)\n' +
9
+ ' at http://localhost:3002/[param]/script.js:1:644\n' +
10
+ ' at http://localhost:3002/[param]/(group)/script.js:1:644\n' +
11
+ ' at http://localhost:3002/(group)/script.js:1:644' ;
12
+
4
13
describe ( 'Tracekit - Chrome Tests' , ( ) => {
5
14
it ( 'should parse Chrome error with no location' , ( ) => {
6
15
const NO_LOCATION = { message : 'foo' , name : 'bar' , stack : 'error\n at Array.forEach (native)' } ;
@@ -579,6 +588,7 @@ describe('Tracekit - Chrome Tests', () => {
579
588
name : 'Error' ,
580
589
stack : `Error: bad
581
590
at something (http://localhost:5000/(some)/(thing)/index.html:20:16)
591
+ at http://localhost:5000//(group)/[route]/script.js:1:126
582
592
at more (http://localhost:5000/(some)/(thing)/index.html:25:7)` ,
583
593
} ;
584
594
@@ -596,6 +606,13 @@ describe('Tracekit - Chrome Tests', () => {
596
606
colno : 7 ,
597
607
in_app : true ,
598
608
} ,
609
+ {
610
+ filename : 'http://localhost:5000/(group)/[route]/script.js' ,
611
+ function : '?' ,
612
+ lineno : 1 ,
613
+ colno : 126 ,
614
+ in_app : true ,
615
+ } ,
599
616
{
600
617
filename : 'http://localhost:5000/(some)/(thing)/index.html' ,
601
618
function : 'something' ,
Original file line number Diff line number Diff line change @@ -311,6 +311,41 @@ describe('Tracekit - Firefox Tests', () => {
311
311
} ) ;
312
312
} ) ;
313
313
314
+ it ( 'should correctly parse parentheses' , ( ) => {
315
+ const PARENTHESIS_FRAME_EXCEPTION = {
316
+ message : 'aha' ,
317
+ name : 'Error' ,
318
+ stack :
319
+ 'onClick@http://localhost:3002/_next/static/chunks/app/(group)/[route]/script.js:1:644\n' +
320
+ '@http://localhost:3002/_next/static/chunks/app/(group)/[route]/script.js:1:126' ,
321
+ } ;
322
+
323
+ const stacktrace = exceptionFromError ( parser , PARENTHESIS_FRAME_EXCEPTION ) ;
324
+
325
+ expect ( stacktrace ) . toEqual ( {
326
+ value : 'aha' ,
327
+ type : 'Error' ,
328
+ stacktrace : {
329
+ frames : [
330
+ {
331
+ colno : 126 ,
332
+ filename : 'http://localhost:3002/_next/static/chunks/app/(group)/[route]/script.js' ,
333
+ function : '?' ,
334
+ in_app : true ,
335
+ lineno : 1 ,
336
+ } ,
337
+ {
338
+ colno : 644 ,
339
+ filename : 'http://localhost:3002/_next/static/chunks/app/(group)/[route]/script.js' ,
340
+ function : 'onClick' ,
341
+ in_app : true ,
342
+ lineno : 1 ,
343
+ } ,
344
+ ] ,
345
+ } ,
346
+ } ) ;
347
+ } ) ;
348
+
314
349
it ( 'should parse Firefox errors with `file` inside an identifier' , ( ) => {
315
350
const FIREFOX_FILE_IN_IDENTIFIER = {
316
351
stack :
Original file line number Diff line number Diff line change @@ -320,4 +320,39 @@ describe('Tracekit - Safari Tests', () => {
320
320
} ,
321
321
} ) ;
322
322
} ) ;
323
+
324
+ it ( 'should correctly parse parentheses' , ( ) => {
325
+ const PARENTHESIS_FRAME_EXCEPTION = {
326
+ message : 'aha' ,
327
+ name : 'Error' ,
328
+ stack :
329
+ '@http://localhost:3000/(group)/[route]/script.js:1:131\n' +
330
+ 'global code@http://localhost:3000/(group)/[route]/script.js:1:334' ,
331
+ } ;
332
+
333
+ const ex = exceptionFromError ( parser , PARENTHESIS_FRAME_EXCEPTION ) ;
334
+
335
+ expect ( ex ) . toEqual ( {
336
+ value : 'aha' ,
337
+ type : 'Error' ,
338
+ stacktrace : {
339
+ frames : [
340
+ {
341
+ colno : 334 ,
342
+ filename : 'http://localhost:3000/(group)/[route]/script.js' ,
343
+ function : 'global code' ,
344
+ in_app : true ,
345
+ lineno : 1 ,
346
+ } ,
347
+ {
348
+ colno : 131 ,
349
+ filename : 'http://localhost:3000/(group)/[route]/script.js' ,
350
+ function : '?' ,
351
+ in_app : true ,
352
+ lineno : 1 ,
353
+ } ,
354
+ ] ,
355
+ } ,
356
+ } ) ;
357
+ } ) ;
323
358
} ) ;
You can’t perform that action at this time.
0 commit comments