The returned value is a function with a signature of (done). When invoked, it will write to this.err, this.res, and this.body as done in httpUtils.save.

It is expected that you invoke the returned function via a .call or .apply to an asynchronous before context with its callback. This is practical when there is data locked into a this context that needs to be used for a request.

// Prepare some `this` data

before(function(){

this.credentials ={

username:'todd',

password:'keyboardcat'

};

});

// In an asynchronous `before` block

before(function(done){

// Prepare the save call

httpUtils._save({

method:'POST',

url:'http://localhost:8080/login',

form:this.credentials

// Invoke on the current context with the current callback

}).call(this, done);

});

The alternative is to use var's outside of before blocks. Unfortunately, those cannot be re-used while a before function can be.