I am using Chutzpah in Visual Studio 2013 Update 2, and I am trying to do some unit testing using jasmine for AngularJS.
The problem is that for some reason chutzpan thinks my reference javascript files are files to test.
No matter where I include the reference files (in the test file or Chutzpah.json), I get the same errors.
For example, if I include:
/// <reference path="Scripts/angular.js" />
/// <reference path="Scripts/angular-mocks.js" />
/// <reference path="../codeToTest" />
describe('Controller: myController', function () {
beforeEach(module('myApp'));
});
I get:
Error: TypeError: 'undefined' is not an object (evaluating 'angular.mock = {}')
and
ReferenceError: Can't find variable: module in file.
Any ideas where I am wrong?
Thank you!
Update: So guys, I solve the problem just by adding reference files in both test files and chutzpah.json.
You have two choices here. You can either create a chutzpah.json file and include the references there, or you can change /// reference to /// chutzpah_reference
You can find more info here: https://chutzpah.codeplex.com/wikipage?title=Chutzpah%20File%20References
Related
I am writing a setup project for wix v3 in visual studio. The purpose of the project is to install a bunch of files to certain directories and then alter an XML file by setting values for elements. Everything builds fine until I add the XmlFile element to edit the XML file. Here is a code snippet of the element:
<Fragment>
<util:XmlFile
File="[INSTALLDIR]⁄Server/MEScontrol.config"
Id="config"
Action="setValue"
Name="connectionString"
ElementPath="⁄MEScontrol⁄DatabaseServer⁄Package[\[]#name='core'[\]]/add[[]#Assembly[\]]"
Value="[\[]#name='BINGBONG'[\]]" />
</Fragment>
The error I get when building is this:
"The Fragment element contains an unhandled extension element 'util:XmlFile'. Please ensure that the extension for elements in the 'http:⁄⁄schemas.microsoft.com⁄wix⁄UtilExtension' namespace has been provided"
I know that I need to add the namespaces
xmlns="http://schemas.microsoft.com/wix/2006/wi" and
xmlns:util="http://schemas.microsoft.com⁄wix⁄UtilExtension"
to my code and then add the reference WixUtilExtension to the project, which I have done, but I still get this error when building. Is it possible that I miss something in my code or references? I have also tried adding the util:XmlFile element as a Component inside my Directory structure but still the same error
Don't worry everybody I figured it out almost as soon as i posted this question. Apparently the "/" I was using in the namespace was not actually the correct character for a URL and that was causing the error. Silly me
I don't see any intellisense for ReactJS, for example methods like React.createClass although I see _references.js file at the root folder. The _references.js file has help reference to various react js files.
The extension of my react file is JS and not JSX.
I fixed this issue by importing the NuGet package "react.js" and bringing the script locally.
I've also added a _references.js to ~/Scripts/ to my project. Visual Studio had a helper under "add..." entitled "_references.js intellisense file" which looked like this:
/// <autosync enabled="true" />
/// <reference path="bootstrap.js" />
/// <reference path="jquery-2.1.4.js" />
/// <reference path="react/jsxtransformer-0.13.1.js" />
/// <reference path="react/react-0.13.1.js" />
/// <reference path="react/react-with-addons-0.13.1.js" />
After that, I was able to use intellisense in my jsx files. The _references.js file did not seem to like running from Facebook's CDN.
well the title says everything. I've got a class with some comments in it.
Something like
/// <summary>
/// Bla
/// </summary>
The problem is, I can only see those comments inside the project. If I make an reference to this class and use it in an other project, the comments are not visible...
If the project is in the same solution, you can replace the reference with a project reference (the Solution tab in Add Reference).
If not, you need to open Project Properties in the original project and check Generate XML Documentation File in the Build tab.
I'm new to Typescript and have been working the last few days within Visual Studio 2013 Update 2 (which natively includes all support).
I have the following options selected within Visual Studio on the properties page for my project.
This means that when I save a file it will automatically compile all the typescript files together and create a single RRStore.js file. I then just include this using the BundleManager in ASP.NET as if it were any old JS file. I am not using a module loaders since there's not much JS code.
To resolve dependencies in the correct order the TS compiler needs a _references.ts file so I created one like this :
/// <reference path="RR.ErrorHandling.ts" />
/// <reference path="RR.JQueryPlugins.ts" />
/// <reference path="RR.Util.ts" />
/// <reference path="viewmodel/UserViewModel.ts" />
/// <reference path="viewmodel/AddressViewModel.ts" />
/// <reference path="viewmodel/ProductViewModel.ts" />
/// <reference path="viewmodel/CartItemViewModel.ts" />
/// <reference path="viewmodel/CheckoutViewModel.ts" />
/// <reference path="viewmodel/StoreWizardViewModel.ts" />
/// <reference path="viewmodel/DefenderWizardViewModel.ts" />
/// <reference path="viewmodel/MainViewModel.ts" />
/// <reference path="RR.YoutubeLoader.ts" />
This file means when I hit Ctrl+S within Visual Studio after editing a TS file it will combine all my other TS files together in this order so things such as prototype chains are correct for inheritance.
This was working fine on Ctrl+S when saving a TS file.
I then had to make a change to some C# code - after which of course I needed to hit Ctrl+F5 to build the project. To my surprise I got weird JS errors in the browser - about prototypes not existing on objects.
I looked at the generated Typescript file RRStore.js in the browser and examined the order of all my files and it's put the file RR.YoutubeLoader.ts FIRST.
That's weird! (not least because it's LAST on my list of references above.)
I went to that file and hit Ctrl+S, refreshed RRStore.js and everything is back in the right order.
In other words when I do a full build the order of files in _references.ts is not respected, but when I just hit Ctrl+S it is. What's going on?
Edit: Update: Turns out _references.ts needs to be in the root of your project to be recognized by the compiler. So that's the preferred way :-) This method works too... but please don't do this:
Original workaround:
When reading through my generated RRStore.js file I noticed the order seemed to be in an apparently random order: RR.YoutubeLoader, ProductViewModel, DefenderViewModel, StoreViewModel etc.
I realized there could be only one explanation....
I opened up the .csproj file and sure enough the compiler was processing files in the order they had been initially added to my project!!!.
So I moved the _references.ts file up to the first in the MySite.csproj file - and it is now correctly recognizing it and compiling everything in the right order.
I'm not sure if this is a known bug yet but that was an adequate solution for me.
MyProject.csproj
Sooooo....
Apparently _references.ts needs to be in the root of the project.
I haven't tested this but this is a response from https://typescript.codeplex.com/workitem/2592
I still prefer my way of manually editing the csproj file (so my ts files are all inside Scripts/Typescript). Hopefully sometime they'll change this unintuitive behavior and look for _references.ts wherever it is.
I couldn't find any reference to this in the typescript bug tracker, so I have created one at https://typescript.codeplex.com/workitem/2592
i have a jQuery plugin .js file, and a Typescript file in which i want to use the first plugin. after googling that, maybe i need import library.d.ts into my typescript file like following code, and how about that plugin(slof-slider.js)?
/// <reference path="jquery.d.ts"/>
After you have added the following line :
/// <reference path="jquery.d.ts"/>
You need to tell TypeScript about the functions added by SlofSlider (not sure about the name?) e.g. if you want :
$('div').slider();
to compile you would do something like:
interface JQuery {
slider: Function;
}
After adding this reference
/// <reference path="jquery.d.ts"/>
Add the jquery.min library to webpage... that should work fine..