I am using TypeScript 1.0 with Visual Studio 2012, Chutzpah 3.2.1.1 and Jasmine 2.
I have a very basic test which compiles fine, but does not pass using the Visual Studio Chutzpah Test Adaptor or the command line one.
I get the following error
ReferenceError: Can't find variable: MyProject in....
My project is structured like this:
**solution**
TypeScriptProject
X.ts
TestProject
chutzpah.json
compile.bat
Scripts\(contains typings)
Spec
TestX.ts
TypeScriptProject\X.ts
module MyProject {
export class X {
getValue(): number {
return 5;
}
}
}
TestProject\chutzpah.json
{
"Framework": "jasmine",
"Compile": {
"Extensions": [".ts"],
"ExtensionsWithNoOutput": [".d.ts"],
"Executable": "compile.bat"
},
"References": [
{ "Path": "../TypeScriptProject/X.ts"}
],
"Tests": [
{ "Path": "Spec"}
]
}
TestProject\compile.bat
@echo off
tsc Spec/TestX.ts ../TypeScriptProject/X.ts --sourcemap
TestProject\Spec\TestX.ts
/// <reference path="../Scripts/typings/jasmine/jasmine.d.ts"/>
/// <reference path="../../TypeScriptProject/X.ts"/>
describe("test x value", function(){
it("should", function(){
var x = new MyProject.X();
expect(x.getValue()).toEqual(5);
});
});
Since it compiles fine, the references in TestX.ts should be correct.
My problem seems to be different to Chutzpah running Jasmine in TFS 2012 can't find referenced file under test as I get the error in the Visual Studio test runner and seems to be talking about using Team Build.
By default Chutzpah assumes the source and out directory for compilation is the location of the chutzpah.json file. However, in your case those directories should be one higher since you are compiling .ts files that are not at or below the location of the chutzpah.json file.
So by adding the sourcedirectory and outdirectory to the compile settings it will work fine:
{
"Framework": "jasmine",
"Compile": {
"Extensions": [".ts"],
"ExtensionsWithNoOutput": [".d.ts"],
"Executable": "compile.bat",
"SourceDirectory": "../",
"OutDirectory": "../",
},
"References": [
{ "Path": "../TypeScriptProject/X.ts"}
],
"Tests": [
{ "Path": "Spec"}
]
}
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