The first example in readme shows the situation when plan works, but end will not - asynchronous resolution of the test. In this case, you do not explicitly say when all the tests have been solved, you say how many of them should ultimately solve:
test('timing test', function (t) { t.plan(2); t.equal(typeof Date.now, 'function'); var start = Date.now(); setTimeout(function () { t.equal(Date.now() - start, 100); }, 100); });
If we used end , the intuitive way to write this test would be as follows:
test('timing test', function (t) { t.equal(typeof Date.now, 'function'); var start = Date.now(); setTimeout(function () { t.equal(Date.now() - start, 100); }, 100); t.end(); });
... but that would finish the test before the second statement got a chance to run.
You can extrapolate this further to any situation where you need to execute asynchronous or dynamic code.
source share