☕️ Classic, reliable, trusted test framework for Node.js and the browser
persist paths in stack trace which have cwd as infix
Outsider5078fc5325bf
diff --git a/lib/utils.js b/lib/utils.jsindex a32e0a49..a308490a 100644--- a/lib/utils.js+++ b/lib/utils.js@@ -543,7 +543,7 @@ exports.stackTraceFilter = function () {// Clean up cwd(absolute)if (/\(?.+:\d+:\d+\)?$/.test(line)) {- line = line.replace(cwd, '');+ line = line.replace('(' + cwd, '(');}list.push(line);diff --git a/test/node-unit/stack-trace-filter.spec.js b/test/node-unit/stack-trace-filter.spec.jsindex 23cfcd85..08cc3af0 100644--- a/test/node-unit/stack-trace-filter.spec.js+++ b/test/node-unit/stack-trace-filter.spec.js@@ -88,6 +88,23 @@ describe('stackTraceFilter()', function () {expect(filter(stack.join('\n'))).to.equal(expected.join('\n'));});++ it('should not replace absolute path which has cwd as infix', function () {+ var stack = [+ 'Error: /www' + process.cwd() + '/bla.js has a problem',+ 'at foo (/www' + 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: /www' + process.cwd() + '/bla.js has a problem',+ 'at foo (/www' + process.cwd() + '/foo/index.js:13:226)',+ 'at bar (/usr/local/dev/own/tmp/node_modules/bluebird/js/main/promise.js:11:26)'+ ];++ expect(filter(stack.join('\n')))+ .to.equal(expected.join('\n'));+ });});describe('on Windows', function () {