My team and I are working on a web application that has a fair amount of Angular code and Jasmine tests. We're using Visual Studio and ReSharper's built-in Jasmine test runner. For the sake of ReShaper our JS test files all have references paths setup at the top like so
/// <reference path="/path/to/somefile.js" />
We have alot of these references. For every new test file, we have to add these references. If we had a new component or external library, we have to add another reference to almost all of our existing test files. This is particularly true for including external angular modules.
Is there a way that to create a shared reference file for the js tests in resharper? This really becomes a core when your solution contains tons of smaller files
Yes, you can just create a reference file with all other references in it. And then you only need to include that reference file in your js test files.
In the js test file (spec) you just include this:
/// <reference path="defaultReferences.js" />
And in the defaultReferences.js file you add all the references you need:
/// <reference path="../../App/lib/jquery/jquery-2.1.0.js" />
/// <reference path="../../App/lib/jquery/jquery.cookie.js" />
/// <reference path="../../App/lib/angular-1.3.0-beta.3/angular.js" />
Then you only have to add a new reference file in the defaultReferences instead of all
Update
After @sarin 's question below, I will try to explain how my folder structure, in my project looks like: (I also have resharper 8.2 and jasmine 2.0)
.. [WebApp]
.... [lib]
...... [angular]
...... references.js
.... [js]
...... [account]
........ accountController.js
...... [basket]
........ basketService.js
.... [tests]
...... [helpers]
...... [spec]
........ [account]
.......... accountControllerSpec.js
........ [basket]
.......... basketServiceSpec.js
Then in my basketSerivceSpec.js, then references looks like this:
/// <reference path="../../../lib/references.js" />
/// <reference path="../../../js/basket/basketService.js" />
So if you are experiencing that resharper aren't running the test, then look at the references path's.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With