Hi,
I've been experimenting with adding Chutzpah to our TFS 2012 build server. Initially everything looked promising but I encountered a ReferenceError issue as soon as I got beyond the initial use case.
It sounds similar to https://chutzpah.codeplex.com/workitem/217 but whereas they're home and dry I am unfortunately not :-(
The error I encountered was this: (names changed)
```
ReferenceError: Can't find variable: xyz in file:///C:/Builds/1/ [...] /xyzTests.js (line 13)
```
The xyz variable is defined in xyzViewModel.js and it is referenced in the test file like this:
```
/// <reference path="../../../../../Scripts/jasmine.js" chutzpah-exclude="true" />
/// <reference path="../../../../../Scripts/Areas/Views/xyz/xyzViewModel.js" />
```
xyzTests.js was given a BuildAction of ```None``` and a Copy to Output Directory of ```Copy always```.
xyzViewModel.js was given a BuildAction of ```Content``` and I changed the Copy to Output Directory to ```Copy always``` to try and rectify the problem. Unfortunately it didn't fix the issue.
I'm a little stuck now and wondering if I'm missing something.... Any thoughts anyone?
I'm using Chutzpah 3.1, I was following the instructions in the blog post on [Javascript Unit Tests on Team Foundation Service with Chutzpah](http://blogs.msdn.com/b/visualstudioalm/archive/2012/07/09/javascript-unit-tests-on-team-foundation-service-with-chutzpah.aspx) and the version of Chutzpah used on the build server was taken from the [latest VSIX / zip](http://visualstudiogallery.msdn.microsoft.com/f8741f04-bae4-4900-81c7-7c9bfb9ed1fe).
**UPDATE**
I appear to have solved my problem. Step 7 of the blog post I was following says:
> *Make sure that the js files (that contain the tests) are getting copied to the build output directory.*
This appears to suggest that test files should be set to "Copy always". Setting this to actually be "Do not copy" fixed my problem and I was able to confirm that tests were run as expected.
So that's good news and I'm left with 2 small questions if anyone could pitch in:
1. I'm presuming that Chutzpah must have changed since that blog post was written so the "Copy always" step is no longer required. Is there any detail available on that?
2. At present I have a "tests" folder in the root of my web app which duplicates the folder structure of the "scripts" folder and contains any test files appropriately nested. The downside of this is that the tests get pushed out when I hit "publish" which is not really what I want. Is there a straightforward way to prevent this?
Comments: Yes, it will put it in publishedwebsites if you are using a web project
I've been experimenting with adding Chutzpah to our TFS 2012 build server. Initially everything looked promising but I encountered a ReferenceError issue as soon as I got beyond the initial use case.
It sounds similar to https://chutzpah.codeplex.com/workitem/217 but whereas they're home and dry I am unfortunately not :-(
The error I encountered was this: (names changed)
```
ReferenceError: Can't find variable: xyz in file:///C:/Builds/1/ [...] /xyzTests.js (line 13)
```
The xyz variable is defined in xyzViewModel.js and it is referenced in the test file like this:
```
/// <reference path="../../../../../Scripts/jasmine.js" chutzpah-exclude="true" />
/// <reference path="../../../../../Scripts/Areas/Views/xyz/xyzViewModel.js" />
```
xyzTests.js was given a BuildAction of ```None``` and a Copy to Output Directory of ```Copy always```.
xyzViewModel.js was given a BuildAction of ```Content``` and I changed the Copy to Output Directory to ```Copy always``` to try and rectify the problem. Unfortunately it didn't fix the issue.
I'm a little stuck now and wondering if I'm missing something.... Any thoughts anyone?
I'm using Chutzpah 3.1, I was following the instructions in the blog post on [Javascript Unit Tests on Team Foundation Service with Chutzpah](http://blogs.msdn.com/b/visualstudioalm/archive/2012/07/09/javascript-unit-tests-on-team-foundation-service-with-chutzpah.aspx) and the version of Chutzpah used on the build server was taken from the [latest VSIX / zip](http://visualstudiogallery.msdn.microsoft.com/f8741f04-bae4-4900-81c7-7c9bfb9ed1fe).
**UPDATE**
I appear to have solved my problem. Step 7 of the blog post I was following says:
> *Make sure that the js files (that contain the tests) are getting copied to the build output directory.*
This appears to suggest that test files should be set to "Copy always". Setting this to actually be "Do not copy" fixed my problem and I was able to confirm that tests were run as expected.
So that's good news and I'm left with 2 small questions if anyone could pitch in:
1. I'm presuming that Chutzpah must have changed since that blog post was written so the "Copy always" step is no longer required. Is there any detail available on that?
2. At present I have a "tests" folder in the root of my web app which duplicates the folder structure of the "scripts" folder and contains any test files appropriately nested. The downside of this is that the tests get pushed out when I hit "publish" which is not really what I want. Is there a straightforward way to prevent this?
Comments: Yes, it will put it in publishedwebsites if you are using a web project