Search code examples
asp.net-mvcasp.net-mvc-4visual-studio-2012jasminechutzpah

Jasmine in a separate test project


Is it practical/possible to separate jasmine tests into a separate visual studio project?

I am just getting started with angular, and am trying to write my tests before I start on the actual angular implementation. I will be writing my project in Visual Studio 2012 with the Chutzpah test runner, see this video. Currently, I am trying to figure out how to organize my folder structure. I know about angular-seed and yeoman, but those are ill suited to starting a .net project.

I am assuming that since unit tests in Visual Studio are usually separated into a separate test project, by convention, the jasmine tests should, too.

However, for java script, there are no project dlls to reference, so separating the tests out into a different project would require a lot of copy and pasting, I think.


Solution

  • You can do this with no copy/pasting. In your Jasmine tests you can add a /// <reference comment which posts to your source files (or the directory containing them). For example given this sturcture

    /ProjectA /scripts

    code1.js
    code2.js
    

    /TestProjectB test1.js

    You can add this line at the top of your test1.js file to reference all your code files:

    /// <reference path="../scripts" />