Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 29 additions & 27 deletions packages/node/test/stacktrace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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,
},
]);
});
});
2 changes: 1 addition & 1 deletion packages/utils/src/stacktrace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down