Skip to content

Commit

Permalink
Merge pull request #173 from jamestalmage/test-should-fail-without-cb
Browse files Browse the repository at this point in the history
test() should throw if no callback is provided. Fixes #172
  • Loading branch information
sindresorhus committed Nov 9, 2015
2 parents ff8031f + 0dad455 commit 4399e7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ function Test(title, fn) {
title = null;
}

assert.is(typeof fn, 'function', 'you must provide a callback');

this.title = title || fnName(fn) || '[anonymous]';
this.fn = isGenerator(fn) ? co.wrap(fn) : fn;
this.assertCount = 0;
Expand Down
10 changes: 10 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ test('test title is optional', function (t) {
});
});

test('test callback is required', function (t) {
t.throws(function () {
ava();
}, /you must provide a callback/);
t.throws(function () {
ava('title');
}, /you must provide a callback/);
t.end();
});

test('infer test name from function', function (t) {
ava(function foo(a) {
a.end();
Expand Down

0 comments on commit 4399e7b

Please sign in to comment.