We have a Visual Studio 2013 solution for an AngularJS application, written in TypeScript. There is a separate test project for the Jasmine unit tests, also written in TypeScript.
What we are having trouble with is finding a build/Chutzpah configuration that allows us to run the tests on development machines via the Chutzpah test adapter, and also as part of our CI build on Visual Studio Team Services.
When we run the tests on dev machines, it appears that by default the tests run in the source tree, so the dependencies on .d.ts and application .ts files are set up relative to the source directory. So far so good. However when we run the Visual Studio Team Services build (set up following this blog post) the tests seem to run in the bin directory (looking at the Visual Studio Team Services logs). This means the references for dependencies are wrong, so the tests fail as they cannot find the required .d.ts or application .ts files.
The best solution to this we have found so far is this:
- Have Chutzpah.json set to 'Copy always' so it copies to bin dir
- Have all test .ts files set to TypeScriptCompile/Copy always
- Have all test .d.ts file set to Content/Copy always (e.g. jasmine.d.ts)
- Have all .ts files in the application project set to TypeScriptCompile/Copy always
- Update test file dependencies to include additional chutzpah_reference that will be correct for bin dir (using chutzpah_reference means that the VS local build will still complete without errors)
We can then run the tests in VS in two ways:
- from the VS test runner as normal
- by showing all files, locate the bin/Tests directory and right click and 'Run JS Tests' (this is a pretty good indicator that the tests will run correctly on TFS assuming the build def, CI & .runsettings are correctly set up).
We also tried redirecting the JS output to the bin dir, which worked ok in VS, however the VS Team Services build failed to copy the .js files for some reason.
Ideally we would like:
- to avoid having to copy .ts files to the output dir
- to avoid having to add in additional references specifically for the bin dir.
- to use the Chutzpah Compile Mode External (as VS already compiles our TypeScript)