AngularJS + Jasmine not finding mock file

I have a strange problem with Jasime in combination wit AngularJS.

I have a simple test like this:

/// <reference path="../../../../usersite/Scripts/angular.js" /> /// <reference path="../../../../usersite/Scripts/angular-mocks.js" /> /// <reference path="../../../../usersite/Content/App/App.js" /> /// <reference path="../../../../usersite/Content/App/Services/Connectivity.js" /> 'use strict'; describe('Connectivity', function () {     describe('GetVersion', function () {         var connectivity;         beforeEach(function () {             module('fieldCapApp');             inject(function (_connectivity_) {                 connectivity = _connectivity_;             });         });         it('should return current version', function () {             var version = 1;             expect(version).toEqual(1);         });     }); });


When I run this test in the Jasime MVC project it passes (with the correct includes in the View).

Now I am trying to run it through resharper, I have R# set to run in Chrome browser, but I get this response:

ReferenceError: module is not defined
    at Object.<anonymous> (http://localhost:39975/Tests.js:15:13)     at attemptSync (http://localhost:39975/jasmine.js:1510:12)     at QueueRunner.run (http://localhost:39975/jasmine.js:1498:9)     at QueueRunner.execute (http://localhost:39975/jasmine.js:1485:10)     at Spec.Env.queueRunnerFactory (http://localhost:39975/jasmine.js:518:35)     at Spec.execute (http://localhost:39975/jasmine.js:306:10)     at Object.<anonymous> (http://localhost:39975/jasmine.js:1708:37)     at attemptAsync (http://localhost:39975/jasmine.js:1520:12)     at QueueRunner.run (http://localhost:39975/jasmine.js:1496:16)     at QueueRunner.execute (http://localhost:39975/jasmine.js:1485:10)


When I inspect the actual HTML from the test runner I see this:

<!DOCTYPE HTML>
<html>
<head>
  <title>Jasmine Spec Runner: Jasmine Core</title>
  <link rel="shortcut icon" type="image/png" href="favicon.ico" />
  <link rel="stylesheet" type="text/css" href="jasmine_2._0.jasmine.css" />
  <script type="text/javascript" src="jasmine.js"></script> <script type="text/javascript" src="referenceFile?path=C:\Projects\UserSite\Scripts\angular.js"></script>
<script type="text/javascript" src="referenceFile?path=C:\Projects\UserSite\Scripts\angular-mocks.js"></script>
<script type="text/javascript" src="referenceFile?path=C:\Projects\UserSite\Content\App\App.js"></script>
<script type="text/javascript" src="referenceFile?path=C:\Projects\UserSite\Content\App\Services\Connectivity.js"></script>
  <script type="text/javascript" src="resharperutils.js"></script>
  <script type="text/javascript" src="jasmine_2._0.Jasmine2ReSharperReporter.js"></script>
  <script type="text/javascript" src="jasmine_2._0.jasmine-html.js"></script>
  <script type="text/javascript" src="jasmine_2._0.boot.js"></script>
  <script type="text/javascript">
    (function(jasmine) {
      var jasmineEnv = jasmine.getEnv();
      jasmineEnv.updateInterval = 50;
      var resharperReporter = new ReSharperReporter(["Jasmine Connectivity GetVersion should return current version"]);
      jasmineEnv.addReporter(resharperReporter);
      jasmineEnv.specFilter = function(spec) {
        return resharperReporter.specFilter(spec);
      };
    })(jasmine);
  </script>
  <script type="text/javascript" src="Tests.js"></script>
</head>
<body>
</body>
</html>


When using the debugger console it seems that all the files are loaded correctly, but still I just doesn't want to use the angular-mock.js file.

What could be the problem here?

0
5 comments

Hello

Please try installing ReSharper 8.2.1 http://www.jetbrains.com/resharper/download/ and check the issue there.

Thanks!

0

http://devnet.jetbrains.com/people/Alexander.KurakinHi Alexander,

Installed new version but the problem persists, keep getting the exception "ReferenceError: module is not defined".

Just to be clear, the exact same test runs fine in Jasmine 2.0 MVC project and the Chutzpah runner.

0

Hello

  Could you please check which Jasmine version is selected here ReSharper | Options | Tools | Unit Testing | JavaScript Tests | Run Tests With?

Thanks!

0

I just doublechecked and it is on Jasmine 2.0, triple checked on a colleague's PC and has the same results.

0

Looks like the problem is that jasmine.js is referenced before other dependencies.
Could you please try to add jasmine.js to your project and than add reference to it after all other references in test file? This should establish correct order of references in resulting HTML file.
ReSharper 9.0 will support custom HTML harness so that you can define this order once for all tests in solution.

0

Please sign in to leave a comment.