Quantcast
Channel: Chutzpah - A JavaScript Test Runner
Viewing all articles
Browse latest Browse all 1864

Commented Unassigned: TFS 2012 Build Server and ReferenceError: Can't find variable... [221]

$
0
0
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: I seem to have a similar issue. When running the tests on the build server with the 'copy always' flag turned on, I get errors like can't find variable: $. It seems that only the variables used outside the tests (so in the global namespace of the tests file) are causing the errors. This is really strange, because while I get these errors, all tests pass so the references are actually being used in the tests. By setting the flag to ´do not copy´, the errors of most files disappear. There is only one left; the tests.js that is in the folder of bin\_PublishedWebsites still creates the referenceerror of not finding jQuery. The other errors that disappeared weren't in the publishedWebsites, but just in the bin\tests folder.

Viewing all articles
Browse latest Browse all 1864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>