Skip to content

Commit

Permalink
failing exit test for 2nd test() plans
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Mar 25, 2013
1 parent 128c134 commit e7d00be
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,36 @@ tap.test('too few exit', function (t) {
t.notEqual(code, 0);
});
});

tap.test('more planned in a second test', function (t) {
t.plan(2);

var tc = tap.createConsumer();

var rows = [];
tc.on('data', function (r) { rows.push(r) });
tc.on('end', function () {
var rs = rows.map(function (r) {
if (r && typeof r === 'object') {
return { id : r.id, ok : r.ok, name : r.name.trim() };
}
else return r;
});
t.same(rs, [
'TAP version 13',
'first',
{ id: 1, ok: true, name: 'should be equivalent' },
'second',
{ id: 2, ok: true, name: 'should be equivalent' },
'tests 3',
'pass 2',
'fail 1'
]);
});

var ps = spawn(process.execPath, [ __dirname + '/exit/second.js' ]);
ps.stdout.pipe(tc);
ps.on('exit', function (code) {
t.notEqual(code, 0);
});
});
11 changes: 11 additions & 0 deletions test/exit/second.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var test = require('../../');

test('first', function (t) {
t.plan(1);
t.ok(true);
});

test('second', function (t) {
t.plan(2);
t.ok(true);
});

0 comments on commit e7d00be

Please sign in to comment.