Thank you in advance to everyone who reads this - quite a few details on the question.
I am trying to inject javascript testing into our project using Jasmine. Those tests that I wrote work in the browser, but do not use PhantomJS through Resharper.
I guess I missed something regarding the plumbing needed to parse our JS files (maybe I will identify a problem with our JS setup). Any help is much appreciated ...
I have Jasmine test settings inside Visual Studio using jasmine ...
// The Jasmine Test Framework /// <reference path="../jquery-1.10.1.js"/> /// <reference path="lib/jasmine-1.3.1/jasmine.css"/> /// <reference path="lib/jasmine-1.3.1/jasmine.js"/> /// <reference path="lib/jasmine-1.3.1/jasmine-html.js"/> /// <reference path="lib/jasmine-jquery.js"/> /// <reference path="lib/mock-ajax.js"/> // Classes to test /// <reference path="../MyNamespace.Navigation.js"/> describe("Breadcrumbs", function () { it("should have a window object", function() { //this test passes in PhantomJS and the browser expect(window).toBeDefined(); }); it("should have the base object available", function() { //this test only passes in the browser expect(window.MyNamespace).toBeDefined(); }); });
this refers to a js file containing ...
(function (app, $, undefined) { //do things here }(window.MyNameSpace = window.MyNamespace || {}, jQuery));
I have a SpecRunner.html that can run my tests successfully ... this is the specrunner html that comes with Jasmine 1.3.1 standalone with the head edited like that ...
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css"> <script type="text/javascript" src="../jquery-1.10.1.js"></script> <script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script> <script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script> <script type="text/javascript" src="../MyNamespace.Navigation.js"></script> <script type="text/javascript" src="spec/BreadcrumbsSpec.js"></script>
These tests are triggered either by my SpecRunner.html specifier (which works great), or by using the Resharper 7s test resource using PhantomJS, which I assume doesn't evaluate the code in my JS code file ..?
Update: some additional information ...
Resharper Version:
JetBrains ReSharper 7.1.3 Full Edition Build 7.1.3000.2254 on 2013-04-10T16: 48: 18
and Phantom JS Version 1.9.1.0
And I just realized that I have no real mistake in my question - Doh!
TypeError: 'undefined' is not an object (evaluating 'window.MyNamespace.Whatever') in http://localhost:47815/Tests.js (line 26) TypeError: 'undefined' is not an object (evaluating 'window.MyNamespace.Whatever') at BreadcrumbsSpec.js: line 26 at jasmine.js: line 1035 at jasmine.js: line 2053 at jasmine.js: line 2006 at jasmine.js: line 2335 at jasmine.js: line 2053 at jasmine.js:2043
Interestingly, Tests.js is not my file - I think the R # thing.
Ah - Tests.js is my spec file (i.e. BreadcrumbsSpec.js in this case). If I run the switch options to tell Resharper TestRunner to use a browser, I get the same results (i.e. only the window is defined) and a blank page in the browser ...