Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

lib/utils: Only replace absolute -> relative paths for stack lines

Tobias Bieniekdc365082896d
diff --git a/lib/utils.js b/lib/utils.js
index 7c3a8b66..77f6495c 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -733,7 +733,11 @@ exports.stackTraceFilter = function() {
}
// Clean up cwd(absolute)
- list.push(line.replace(cwd, ''));
+ if (/\(?.+:\d+:\d+\)?$/.test(line)) {
+ line = line.replace(cwd, '');
+ }
+
+ list.push(line);
return list;
}, []);
diff --git a/test/utils.js b/test/utils.js
index 31af2cb2..6cebc5ab 100644
--- a/test/utils.js
+++ b/test/utils.js
@@ -119,11 +119,11 @@ describe('utils', function() {
});
it('should replace absolute with relative paths', function() {
- var stack = ['Error: failed'
+ var stack = ['Error: ' + process.cwd() + '/bla.js has a problem'
, 'at foo (' + process.cwd() + '/foo/index.js:13:226)'
, 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)'];
- var expected = ['Error: failed'
+ var expected = ['Error: ' + process.cwd() + '/bla.js has a problem'
, 'at foo (foo/index.js:13:226)'
, 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)'];