Skip to content

Commit c6c4ace

Browse files
committed
[Tests] add tests for 'todo' exit codes
1 parent 2c6818a commit c6c4ace

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

test/exit.js

+54
Original file line numberDiff line numberDiff line change
@@ -148,3 +148,57 @@ tap.test('more planned in a second test', function (t) {
148148
t.notEqual(code, 0);
149149
});
150150
});
151+
152+
tap.test('todo passing', function (t) {
153+
t.plan(2);
154+
155+
var tc = function (rows) {
156+
t.same(stripFullStack(rows.toString('utf8')), [
157+
'TAP version 13',
158+
'# todo pass',
159+
'ok 1 should be truthy # TODO',
160+
'',
161+
'1..1',
162+
'# tests 1',
163+
'# pass 1',
164+
'',
165+
'# ok'
166+
].join('\n') + '\n\n');
167+
};
168+
169+
var ps = spawn(process.execPath, [path.join(__dirname, '/exit/todo.js')]);
170+
ps.stdout.pipe(concat(tc));
171+
ps.on('exit', function (code) {
172+
t.equal(code, 0);
173+
});
174+
});
175+
176+
tap.test('todo failing', function (t) {
177+
t.plan(2);
178+
179+
var tc = function (rows) {
180+
t.same(stripFullStack(rows.toString('utf8')), [
181+
'TAP version 13',
182+
'# todo fail',
183+
'not ok 1 should be truthy # TODO',
184+
' ---',
185+
' operator: ok',
186+
' expected: true',
187+
' actual: false',
188+
' at: Test.<anonymous> ($TEST/exit/todo_fail.js:$LINE:$COL)',
189+
' ...',
190+
'',
191+
'1..1',
192+
'# tests 1',
193+
'# pass 1',
194+
'',
195+
'# ok'
196+
].join('\n') + '\n\n');
197+
};
198+
199+
var ps = spawn(process.execPath, [path.join(__dirname, '/exit/todo_fail.js')]);
200+
ps.stdout.pipe(concat(tc));
201+
ps.on('exit', function (code) {
202+
t.equal(code, 0);
203+
});
204+
});

test/exit/todo.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var test = require('../../');
2+
3+
test('todo pass', { todo: true }, function (t) {
4+
t.plan(1);
5+
t.ok(true);
6+
});

test/exit/todo_fail.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var test = require('../../');
2+
3+
test('todo fail', { todo: true }, function (t) {
4+
t.plan(1);
5+
t.ok(false);
6+
});

0 commit comments

Comments
 (0)