Question about running testbox via CommandBox

Sorry for bugging you with all the questions, but I’m starting to use CommandBox as much as possible now and just trying to find out if there are things I’m doing incorrectly or whether it may be a bug.

I’m writing some integration tests for an API and seeing some errors when I run “testbox run” that I don’t see if I run the same tests in the browser. I’m wondering if it has to do with headers not being present when running tests via console.

I may even be writing these tests incorrectly as this is my first time writing any tests in TestBox and ColdBox. So feel free to tell me I’m doing this completely wrong, but the test passes in the browser so hopefully it’s close.

My spec looks like:

function run(){

describe( “Maintenance Plan”, function(){

beforeEach(function( currentSpec ){
// Setup as a new ColdBox request for this suite, VERY IMPORTANT. ELSE EVERYTHING LOOKS LIKE THE SAME REQUEST.
setup();

});

it( “+lists maintanance plans”, function(){
var event = execute( “api.accounting.MaintenancePlan.list”);

expect( event.getRenderData().contentType ).toBe( “application/json” );
expect( event.getRenderData().data ).toBeTypeOf( “struct” );
expect( event.getRenderData().data ).toHaveKey( “success” );
});

});

}

I don’t typically like to have a lot of expectations but I kept throwing them in when I started seeing the errors.

The issue seems to be that getRenderData() is completely empty but like I said, in the browser all expectations pass.

If this should be posted in the ColdBox group just let me know, but it seemed appropriate to post here since I don’t think it’s a testbox issue.

Thanks,
Ben

You can actually ignore this. I found the issue.

For some reason when the test runs in the browser my security interceptor runs correctly and allows access to that handlers action, but when running the test with commandbox the security interceptor is stopping the execution of the call and preventing the handler action from firing.

If I fake some data the interceptor expects in the beforeEach() method I’m able to hit handler action successfully.

I’ll have to look at my interceptor to see what’s going on there. It’s still odd that the test passes in the browser and executes that action ok.