diff --git a/packages/node/test/stacktrace.test.ts b/packages/node/test/stacktrace.test.ts index e84c436364ed..f5a1b453609f 100644 --- a/packages/node/test/stacktrace.test.ts +++ b/packages/node/test/stacktrace.test.ts @@ -120,33 +120,6 @@ describe('Stack parsing', () => { ]); }); - test('parses with missing column numbers', () => { - const err = new Error(); - err.stack = - 'AssertionError: true == false\n' + - ' at Test.fn (/Users/felix/code/node-fast-or-slow/test/fast/example/test-example.js:6)\n' + - ' at Test.run (/Users/felix/code/node-fast-or-slow/lib/test.js:45)'; - - const frames = parseStackFrames(stackParser, err); - - expect(frames).toEqual([ - { - filename: '/Users/felix/code/node-fast-or-slow/lib/test.js', - module: 'test', - function: 'Test.run', - lineno: 45, - in_app: true, - }, - { - filename: '/Users/felix/code/node-fast-or-slow/test/fast/example/test-example.js', - module: 'test-example', - function: 'Test.fn', - lineno: 6, - in_app: true, - }, - ]); - }); - test('parses with native methods', () => { const err = new Error(); err.stack = @@ -379,4 +352,33 @@ describe('Stack parsing', () => { }, ]); }); + + test('parses with colons in paths', () => { + const err = new Error(); + err.stack = + 'AssertionError: true == false\n' + + ' at Test.run (/Users/felix/code/node-fast-or-slow/lib/20:20:20/test.js:45:10)\n' + + ' at TestCase.run (/Users/felix/code/node-fast-or-slow/lib/test_case.js:61:8)\n'; + + const frames = parseStackFrames(stackParser, err); + + expect(frames).toEqual([ + { + filename: '/Users/felix/code/node-fast-or-slow/lib/test_case.js', + module: 'test_case', + function: 'TestCase.run', + lineno: 61, + colno: 8, + in_app: true, + }, + { + filename: '/Users/felix/code/node-fast-or-slow/lib/20:20:20/test.js', + module: 'test', + function: 'Test.run', + lineno: 45, + colno: 10, + in_app: true, + }, + ]); + }); }); diff --git a/packages/utils/src/stacktrace.ts b/packages/utils/src/stacktrace.ts index d044e19fa7b7..5c183b71a568 100644 --- a/packages/utils/src/stacktrace.ts +++ b/packages/utils/src/stacktrace.ts @@ -100,7 +100,7 @@ type GetModuleFn = (filename: string | undefined) => string | undefined; // eslint-disable-next-line complexity function node(getModule?: GetModuleFn): StackLineParserFn { const FILENAME_MATCH = /^\s*[-]{4,}$/; - const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/; + const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/; // eslint-disable-next-line complexity return (line: string) => {