Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When t.end() is not called, print the name. #498

Merged
merged 1 commit into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Test.prototype._exit = function () {
exiting: true
});
} else if (!this.ended) {
this.fail('test exited without ending', {
this.fail('test exited without ending: ' + this.name, {
exiting: true
});
}
Expand Down
33 changes: 33 additions & 0 deletions test/exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,36 @@ tap.test('todo failing', function (t) {
t.equal(code, 0);
});
});

tap.test('forgot to call t.end()', function (t) {
t.plan(2);

var tc = function (rows) {
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# first',
'ok 1 should be truthy',
'# oops forgot end',
'ok 2 should be truthy',
'not ok 3 test exited without ending: oops forgot end',
' ---',
' operator: fail',
' at: process.<anonymous> ($TAPE/index.js:$LINE:$COL)',
' stack: |-',
' Error: test exited without ending: oops forgot end',
' [... stack stripped ...]',
' ...',
'',
'1..3',
'# tests 3',
'# pass 2',
'# fail 1'
].join('\n') + '\n\n');
};

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

var test = require('../../');

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

test('oops forgot end', function (t) {
t.ok(true);
});