I am using Chutzpah to run our Jasmine tests. I have added the Chutzpah dlls to the solution and updated the build to run *.js tests.
The project structure is as follows:
MyApp.Web
Scripts
App
Home
DateControl.js
MyApp.Web.Tests
Scripts
Jasmine
lib
Chutzpah (dlls)
Spec
App
Home
DateControlSpecs.js
The Jasmine test file uses a reference tag to reference the file to be tested
/// <reference path="../../../../../../App.web/scripts/app/home/datecontrol.js" />
The Jasmine tests are run however I get the following error:
ReferenceError: Can't find variable: dateControl in file
dateControl is the object under test. If I copy the code to be tested into the Jasmine test file then the tests pass. The jasmine tests with the reference tag pass using the Chutzpah Test Adapter in Test Explorer in Visual Studio 2013.
I have no idea why this is not working.
Update
@jessehouwing's answer pointed out the route of the issue for me.
The build folder on the build server has the following structure
bin _PublishedWebsites src
The jasmine test scripts and libraries are copied to bin whereas the script files under test are copied to both the src directory and the _publishedwebsite directory.
I am looking for an easy to manage solution so that any future devs do not need to know they need to link any new scripts into the test project.