If you’re like me, you got your tests running in Visual Studio(VS). Then you moved on to other priorities. When you returned, some of the javascript unit tests started failing. The problem is that you didn’t know when. You thought to yourself “this should be part of the application’s build process”.

First, head to a great article called “Javascript Unit Tests on Team Foundation Service with Chutzpah“. I completed most of the preliminary work and forged ahead. My javascript tests (using jasmine in my case) still failed.

I turned on tracing, because there’s got to be loads of useful information in those logs. I added the .runsettings file according to the chutzpah wiki. The .runsettings file looked like the below.

After doing this, I received the following error.

An exception occurred while invoking executor ‘executor://chutzpah-js/’: An error occurred while initializing the settings provider named ‘ChutzpahAdapterSettings’. Error: There is an error in XML document (4, 5).There is an error in XML document (4, 5).The string ‘True’ is not a valid Boolean value.

In an effort to rule out the obvious, I changed the “True” to “true” so it looked like this.

To my surprise, it worked took me to the next error. Chutzpah generates a trace file at

c:\users\{build_user}\AppData\Local\Temp

on the build agent machine. I opened up the trace file to find the following error.

vstest.executionengine.x86.exe Information: 0 : Time:11:57:10.4535821; Thread:10; Message:Chutzpah.json file not found given starting directory \content\js

I added the Chutzpah.json file using the wiki page as a reference. All javascript tests and the chutzpah.json must be set to copy always.

ReferenceError: Can’t find variable: {ClassName} in file:///D:/Builds/4/CI.Test/bin/content/js/file.test.js (line 24)
attemptSync@file:///C:/Users/svc_tfsbuild/AppData/Local/Temp/BuildAgent/4/Assemblies/TestFiles/jasmine/v2/jasmine.js:1886:28
run@file:///C:/Users/svc_tfsbuild/AppData/Local/Temp/BuildAgent/4/Assemblies/TestFiles/jasmine/v2/jasmine.js:1874:20
execute@file:///C:/Users/svc_tfsbuild/AppData/Local/Temp/BuildAgent/4/Assemblies/TestFiles/jasmine/v2/jasmine.js:1859:13
queueRunnerFactory@file:///C:/Users/svc_tfsbuild/AppData/Local/Temp/BuildAgent/4/Assemblies/TestFiles/jasmine/v2/jasmine.js:697:42
execute@file:///C:/Users/svc_tfsbuild/AppData/Local/Temp/BuildAgent/4/Assemblies/TestFiles/jasmine/v2/jasmine.js:359:28<mailto:execute@file:///C:/Users/svc_tfsbuild/AppData/Local/Temp/BuildAgent/4/Assemblies/TestFiles/jasmine/v2/jasmine.js:359:28>

I added references at the top of the file that took the TFS build agent src folder structure into account. I followed the same pattern as this stackoverflow question. Once I did that, all my javascript unit tests hummed along.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s