Yeah, we found that beforeAll exposes pretty much none of the normal interface (i.e. console.log( this ) => { } ).
Instead, we just use beforeAll to initialize spec-scoped variables. This means that you need to import your own sinon if you want to stub during beforeAll, which is pretty rubbish in my opinion....
This code works:
var buster = require("buster");
var sinon = require("sinon");
var Baz = { qux: function() { } };
buster.spec.expose();
describe( "foo", function() {
describe( "bar", function() {
var beforeAllStub;
beforeAll( function() {
beforeAllStub = sinon.stub(Baz,'qux').callsArgWith( 2, null, {
foobar: 1,
bazqux: 'testResult'
} );
} );
before( function() {
var context = this;
beforeAllStub( "arg1", "arg2", function( err, result ) {
context.callbackResult = result;
} );
} );
it( "it should have returned the test result", function() {
expect( this.callbackResult ).toMatch( {
foobar: 1,
bazqux: "testResult"
} );
} );
} );
} );