Skip to content

Commit 3bbcef2

Browse files
committed
Add a failling test for node paths with parens
1 parent a3bf972 commit 3bbcef2

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

spec/error-stack-parser-spec.js

+8
Original file line numberDiff line numberDiff line change
@@ -230,5 +230,13 @@ describe('ErrorStackParser', function() {
230230
expect(stackframes[0].lineNumber).toBe(2);
231231
expect(stackframes[0].columnNumber).toBe(9);
232232
});
233+
234+
it('should handle parentheses in Node.js stacks', function() {
235+
var stackframes = unit.parse(CapturedExceptions.NODE_WITH_PARENTHESES);
236+
expect(stackframes.length).toBe(7);
237+
expect(stackframes[0].fileName).toEqual('/var/app/scratch/my project (top secret)/index.js');
238+
expect(stackframes[0].lineNumber).toBe(2);
239+
expect(stackframes[0].columnNumber).toBe(9);
240+
});
233241
});
234242
});

spec/fixtures/captured-errors.js

+28
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,31 @@ CapturedExceptions.NODE_WITH_SPACES = {
397397
'Function.Module.runMain (internal/modules/cjs/loader.js:837:10)\n at ' +
398398
'internal/main/run_main_module.js:17:11'
399399
};
400+
401+
CapturedExceptions.NODE_WITH_SPACES = {
402+
name: 'Error',
403+
message: '',
404+
stack: 'Error\n at Object.<anonymous> ' +
405+
'(/var/app/scratch/my ' +
406+
'project/index.js:2:9)\n at Module._compile ' +
407+
'(internal/modules/cjs/loader.js:774:30)\n at ' +
408+
'Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)\n ' +
409+
' at Module.load (internal/modules/cjs/loader.js:641:32)\n at ' +
410+
'Function.Module._load (internal/modules/cjs/loader.js:556:12)\n at ' +
411+
'Function.Module.runMain (internal/modules/cjs/loader.js:837:10)\n at ' +
412+
'internal/main/run_main_module.js:17:11'
413+
};
414+
415+
CapturedExceptions.NODE_WITH_PARENTHESES = {
416+
name: 'Error',
417+
message: '',
418+
stack: 'Error\n at Object.<anonymous> ' +
419+
'(/var/app/scratch/my ' +
420+
'project (top secret)/index.js:2:9)\n at Module._compile ' +
421+
'(internal/modules/cjs/loader.js:774:30)\n at ' +
422+
'Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)\n ' +
423+
' at Module.load (internal/modules/cjs/loader.js:641:32)\n at ' +
424+
'Function.Module._load (internal/modules/cjs/loader.js:556:12)\n at ' +
425+
'Function.Module.runMain (internal/modules/cjs/loader.js:837:10)\n at ' +
426+
'internal/main/run_main_module.js:17:11'
427+
};

0 commit comments

Comments
 (0)