beforeEach not called via Karma/ Jasmine in an angularjs/ requirejs scenario
<p>Running my unit tests locally works fine but on the build server the most stupid thing happens: Sometimes they pass, sometimes they don't. The main code:</p>

<pre><code>define(['angmock', 'someMore'], function () {
    describe('myController', function () {
        beforeEach(function () {
        console.log("Entry - Initializing modules...");
        module('module1');
        module('module2');
        console.log("Exit - Initializing modules...");
    });

    var scope, controller;
    beforeEach(inject(function ($rootScope, $controller) {
        console.log("Entry - Creating scope...");

        scope = $rootScope.$new();
        controller = $controller('myController', {
            $scope: scope
        });

        console.log("Exit - Creating scope...");
    }));

    it('should test something', function () {
        console.log("Entry - Test A");
        scope.myImportantAssignment = variableName;
        ...
        console.log("Exit - Test A");
    });
...
</code></pre>

<p>In the build server log I can sometimes read:</p>

<blockquote>
  <p>TypeError: undefined is not an object (evaluating
  'scope.myImportantAssignment = variableName')</p>
</blockquote>

<p>And on the console I can read:</p>

<ul>
<li>LOG: 'Entry - Initializing modules...' </li>
<li>LOG: 'Exit - Initializing modules...' </li>
<li>LOG: 'Entry - Test A'</li>
</ul>

<p>That could show that the second beforeEach is not called at all and thus the scope is not initialized. But why? In my easy mind the processing should work like:</p>

<ul>
<li>beforeEach 1</li>
<li>beforeEach 2</li>
<li>it</li>
</ul>

<p>But that does not seem to be the case. Is there probably some problems with async? Any little hint is greatly appreciated as I can not use the tests at all if they are sometimes failing... </p>