Skip to content

Commit

Permalink
Show full path in error traces
Browse files Browse the repository at this point in the history
  • Loading branch information
execjosh committed Nov 20, 2014
1 parent d6118ec commit e9b4d76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/assert/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function errorDiff(err, type) {
}

function extractPathFromStack(stack) {
var regex = /([a-zA-Z0-9._-]+\.(?:js|coffee))(:\d+):\d+/;
var regex = /\((.*?[a-zA-Z0-9._-]+\.(?:js|coffee))(:\d+):\d+\)/;
return stack.match(regex);
}

Expand Down
16 changes: 15 additions & 1 deletion test/assert-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,21 @@ vows.describe('vows/assert').addBatch({
assert.notIncludes([1, 2, 3], 4);
assert.notIncludes({"red": 1, "blue": 2}, "green");
}
}
},

'An AssertionError': {
topic: function generateAssertionError() {
try {
assert.isFalse(true);
} catch (e) {
return e.toString();
}
},
'should have full path in stack trace': function(topic) {
var regexp = new RegExp("// " + __filename + ":\\d+");
assert.isTrue(regexp.test(topic));
}
},
}).export(module);

function assertError(assertion, args, fail) {
Expand Down

0 comments on commit e9b4d76

Please sign in to comment.