I've got an issue running my midway tests (aka. integration tests, which means they are half-way between unit tests and E2E tests).

My build is AngularJS with RequireJS (which in Karma requires using the RequireJS plugin to get the tests running). I'm actually using a plugin called AngularAMD to make those work together. So when I run my tests, first a bootstrap file has to execute to make sure that the Angular app was initialized, before the tests can run against the app.

Since they are integration tests, they are checking that the services are connecting with the real http requests, and that the transformation is taking place (ie. that a user who was logged out is now logged in). So, these are asynchronous tests that require time to receive a response.

My problem -- Karma/Jasmine seems to be bootstrapping the angular app only once at the beginning, and then each test seems to be using this instance when running its tests. So if there is a service being used in two tests, with a persistent cache state (ie. user is logged in), each test is pulling from the same state.

So for example, I've got one integration test that needs a user to be logged-out, and another integration test that needs a user to be logged-in, so each is interfering with the other.

Is it possible to somehow setup Karma/Jasmine that each test file will bootstrap it's own AngularJS instance to test against? I'm trying to figure out how to do that, but I think it may not be possible, unless I force Karma/Jasmine to run one test at a time.

Thoughts?