Skip to content

Commit 3d1217a

Browse files
author
cloudhead
committed
detect un-fired vows on exit, and report error
1 parent e1d1ea5 commit 3d1217a

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/vows.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,31 @@ process.addListener('exit', function () {
139139
vows.reporter.report(['error', { error: "Asynchronous Error", suite: s }]);
140140
}
141141
s.batches.forEach(function (b) {
142+
var unFired = [];
143+
144+
b.vows.forEach(function (vow) {
145+
if (! vow.status) {
146+
if (unFired.indexOf(vow.context) === -1) {
147+
unFired.push(vow.context);
148+
}
149+
}
150+
});
151+
152+
if (unFired.length > 0) { sys.print('\n') }
153+
154+
unFired.forEach(function (title) {
155+
sys.puts(console.error({
156+
error: "not fired!",
157+
context: title,
158+
batch: b,
159+
suite: s
160+
}));
161+
});
162+
142163
if (b.status === 'begin') {
143164
failure = true;
144165
results.errored ++;
145166
results.total ++;
146-
vows.reporter.report(['error', { error: "A callback hasn't fired", batch: b, suite: s }]);
147167
}
148168
Object.keys(results).forEach(function (k) { results[k] += b[k] });
149169
});

lib/vows/console.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,8 @@ this.result = function (event) {
7272
this.inspect = function inspect(val) {
7373
return '\033[1m' + eyes(val) + '\033[22m';
7474
};
75+
76+
this.error = function (obj) {
77+
return '✗ ' + $('Errored ').red + '» '
78+
+ $('' + $(obj.context).italic + ' ∙ ' + obj.error).red;
79+
};

0 commit comments

Comments
 (0)