Chutzpah running Jasmine on TFS 2012 cannot find file link under testing

I use Chutzpah to run Jasmine tests. I added the Chutzpah DLL to the solution and updated the assembly to run * .js tests.

The structure of the project 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 link tag to link to the file being verified

 /// <reference path="../../../../../../App.web/scripts/app/home/datecontrol.js" /> 

Jasmine tests run, however I get the following error:

 ReferenceError: Can't find variable: dateControl in file 

dateControl - the checked object. If I copy the testing code into a Jasmine test file, then the tests will pass. Jasmine tests with a 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 the way for me.

The build folder on the build server has the following structure

bin _PublishedWebsites SRC

Jasmine scripts and libraries are copied to bin, and test script files are copied to both the src directory and the _publishedwebsite directory.

I am looking for a convenient solution, so future developers do not need to know that they need to associate any new scripts with a test project.

+4
tfs jasmine tfs2012 chutzpah
source share
2 answers

The decision I can live with now

For both jasmine test files and test files, I added "Always copy" properties according to the Chutzpah documentation. I did not understand that the files under testing are actually copied to the folder with the assembly bits along with the jasmine test files. So, on the build server, I ended up with the following structure

 bin scripts app * application js files specs * jasmine test files 

In my jasmine test file, I add two links:

  • The first structure of the scanned file in the Visual Studio directory
  • Second assembly basket structure structure

Hack 1

I can get it working by adding another link to my jasmine test file, which uses the build directory structure rather than the solution catalog structure, but again this is open to error, as the path may not be entered correctly.

The second link below allows you to run tests in both VS Test Explorer and TFS Build

 /// <reference path="../../../../../../App.Web/scripts/app/home/datecontrol.js" /> /// <reference path="../../../../../_PublishedWebsites\App.Web/scripts/app/home/datecontrol.js" /> 

Hack 2

By adding the xcopy command to the build event after the build of the project, I can copy the files to be tested to the same location as the jasmine test files.

+3
source share

This is most likely due to the fact that Team Build separates the Sources and Binaries folders and applies a different output structure to the Binaries folder. This means that your files are not where you expect them to be.

To make sure that the test runner can always find your links, you should use the "Add as link" option in Visual Studio and set the build action to "Always copy" so that they are copied to the test directory when the test runs.

In addition, you may need to enable "Deployment" in the test configuration in your assembly definition, as described here .

+1
source share

All Articles