Skip to content

Commit e7d00be

Browse files
author
James Halliday
committedMar 25, 2013
failing exit test for 2nd test() plans
1 parent 128c134 commit e7d00be

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
 

‎test/exit.js

+33
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,36 @@ tap.test('too few exit', function (t) {
106106
t.notEqual(code, 0);
107107
});
108108
});
109+
110+
tap.test('more planned in a second test', function (t) {
111+
t.plan(2);
112+
113+
var tc = tap.createConsumer();
114+
115+
var rows = [];
116+
tc.on('data', function (r) { rows.push(r) });
117+
tc.on('end', function () {
118+
var rs = rows.map(function (r) {
119+
if (r && typeof r === 'object') {
120+
return { id : r.id, ok : r.ok, name : r.name.trim() };
121+
}
122+
else return r;
123+
});
124+
t.same(rs, [
125+
'TAP version 13',
126+
'first',
127+
{ id: 1, ok: true, name: 'should be equivalent' },
128+
'second',
129+
{ id: 2, ok: true, name: 'should be equivalent' },
130+
'tests 3',
131+
'pass 2',
132+
'fail 1'
133+
]);
134+
});
135+
136+
var ps = spawn(process.execPath, [ __dirname + '/exit/second.js' ]);
137+
ps.stdout.pipe(tc);
138+
ps.on('exit', function (code) {
139+
t.notEqual(code, 0);
140+
});
141+
});

‎test/exit/second.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var test = require('../../');
2+
3+
test('first', function (t) {
4+
t.plan(1);
5+
t.ok(true);
6+
});
7+
8+
test('second', function (t) {
9+
t.plan(2);
10+
t.ok(true);
11+
});

0 commit comments

Comments
 (0)
Please sign in to comment.