Currently experiencing challenges while running my midway tests (or integration tests, which are halfway between unit tests and E2E tests).
Working with an AngularJS build featuring RequireJS, I am utilizing the RequireJS plugin in Karma to run the tests. To ensure compatibility, I'm using a plugin called AngularAMD to integrate both frameworks seamlessly. When initiating the tests, a bootstrap file must execute first to initialize the Angular app before the tests can proceed.
As these tests focus on checking the connection of services with real HTTP requests and ensuring that transformations occur (such as transitioning from a logged-out to a logged-in state), they are asynchronous and require time to receive responses.
The issue at hand is that Karma/Jasmine seems to only bootstrap the Angular app once initially, causing each subsequent test to use the same instance for testing. This results in conflicts when a service is used across multiple tests with persistent cache states like a logged-in user scenario.
For instance, I have one integration test requiring a logged-out user and another needing a logged-in user, causing interference between the two scenarios.
Is there a way to configure Karma/Jasmine so that each test file initiates its own separate AngularJS instance for testing purposes? I am exploring potential solutions but suspect it may be impossible unless I compel Karma/Jasmine to run tests sequentially.
Your input would be greatly appreciated.