-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
Passing t.end as a callback is a nice feature of tape. It'll end the test & automatically check first arg for an error.
If one wants to use AVA's t.end as a callback though, firstly, it doesn't check for error arg, but secondly it will break due to references to this.
This would provide built-in support for node's errback pattern, echoing AVA's built-in support for promises.
Current implementation:
Test.prototype.end = function () {
if (this.endCalled) {
throw new Error('.end() called more than once');
}
this.endCalled = true;
this.exit();
};All AVA Test methods face this issue, perhaps they should all be forcibly bound to the current instance, though t.end is probably by far the most useful one to have bound.
This may be is too much magic though, mainly raising as I noticed this didn't work when migrating my tape tests.