Skip to content

Commit 5dced8e

Browse files
ppmathisindexzero
authored andcommitted
Fixed recursive call of assertion errors which led to a huge delay when a test failed - Fixes #278
1 parent bc7cad0 commit 5dced8e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/assert/error.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ function errorDiff(err, type) {
7575
}).join('');
7676
}
7777

78-
require('assert').AssertionError.prototype.toString = function () {
78+
/*
79+
Do not override .toString() when this.stack is used,
80+
otherwise this will end in an endless recursive call...
81+
See issue https://github.com/cloudhead/vows/issues/278#issuecomment-22837493
82+
*/
83+
require('assert').AssertionError.prototype.toStringEx = function () {
7984
var that = this,
8085
source;
8186

lib/vows.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function addVow(vow) {
136136
output('honored');
137137
} catch (e) {
138138
if (e.name && e.name.match(/AssertionError/)) {
139-
output('broken', e.toString().replace(/\`/g, '`'));
139+
output('broken', e.toStringEx().replace(/\`/g, '`'));
140140
} else {
141141
output('errored', e.stack || e.message || e);
142142
}

0 commit comments

Comments
 (0)