Skip to content

Commit

Permalink
[Breaking] tests with no callback are failed TODO tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aychtang authored and ljharb committed Mar 16, 2014
1 parent 89f2010 commit 03529a9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
3 changes: 3 additions & 0 deletions example/no_callback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var test = require('../');

test('No cb test');
3 changes: 3 additions & 0 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ Test.prototype.end = function (err) {

Test.prototype._end = function (err) {
var self = this;

if (!this._cb && !this._todo) this.fail('# TODO ' + this.name);

if (this._progeny.length) {
var t = this._progeny.shift();
t.on('end', function () { self._end(); });
Expand Down
36 changes: 34 additions & 2 deletions test/no_callback.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
var test = require('../');
var tape = require('../');
var tap = require('tap');
var concat = require('concat-stream');

test('No callback.');
var stripFullStack = require('./common').stripFullStack;

tap.test('no callback', function (tt) {
tt.plan(1);

var test = tape.createHarness();
var tc = function (rows) {
var body = stripFullStack(rows.toString('utf8'));

tt.same(body, [
'TAP version 13',
'# No callback.',
'not ok 1 # TODO No callback.',
' ---',
' operator: fail',
' stack: |-',
' Error: # TODO No callback.',
' [... stack stripped ...]',
' ...',
'',
'1..1',
'# tests 1',
'# pass 0',
'# fail 1',
].join('\n') + '\n');
};

test.createStream().pipe(concat(tc));

test('No callback.');
});

0 comments on commit 03529a9

Please sign in to comment.