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 11import { exceptionFromError } from '../../../src/eventbuilder' ;
22import { defaultStackParser as parser } from '../../../src/stack-parsers' ;
33
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+
413describe ( 'Tracekit - Chrome Tests' , ( ) => {
514 it ( 'should parse Chrome error with no location' , ( ) => {
615 const NO_LOCATION = { message : 'foo' , name : 'bar' , stack : 'error\n at Array.forEach (native)' } ;
@@ -579,6 +588,7 @@ describe('Tracekit - Chrome Tests', () => {
579588 name : 'Error' ,
580589 stack : `Error: bad
581590 at something (http://localhost:5000/(some)/(thing)/index.html:20:16)
591+ at http://localhost:5000//(group)/[route]/script.js:1:126
582592 at more (http://localhost:5000/(some)/(thing)/index.html:25:7)` ,
583593 } ;
584594
@@ -596,6 +606,13 @@ describe('Tracekit - Chrome Tests', () => {
596606 colno : 7 ,
597607 in_app : true ,
598608 } ,
609+ {
610+ filename : 'http://localhost:5000/(group)/[route]/script.js' ,
611+ function : '?' ,
612+ lineno : 1 ,
613+ colno : 126 ,
614+ in_app : true ,
615+ } ,
599616 {
600617 filename : 'http://localhost:5000/(some)/(thing)/index.html' ,
601618 function : 'something' ,
Original file line number Diff line number Diff line change @@ -311,6 +311,41 @@ describe('Tracekit - Firefox Tests', () => {
311311 } ) ;
312312 } ) ;
313313
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+
314349 it ( 'should parse Firefox errors with `file` inside an identifier' , ( ) => {
315350 const FIREFOX_FILE_IN_IDENTIFIER = {
316351 stack :
Original file line number Diff line number Diff line change @@ -320,4 +320,39 @@ describe('Tracekit - Safari Tests', () => {
320320 } ,
321321 } ) ;
322322 } ) ;
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+ } ) ;
323358} ) ;
You can’t perform that action at this time.
0 commit comments