I am using QUnit to test my typescript code and everything is fine when I run a simple example like this: http://thomasardal.com/testing-typescript-with-typescript-using-qunit-and-chutzpah/
But my nightmare start when I try create unit tests for my SPA app. At the moment to run the testing using Chutzpah on my VS I got a strange error: "Can't Find variable home in mypath\home.tests.ts(line6).
My Code bellow:
home.ts
import logger = module('services/logger');
export var title = 'Home View';
export function activate() {
logger.log('Home View Activated', null, 'home', true);
return true;
}
home.tests.ts
/// <reference path="../../Scripts/qunit.d.ts" />
QUnit.module("home.ts tests");
import home = module("home");
test("test title from home viewmodel", function () {
// Calling to active public function from home viewmodel. (home.ts)
var activateResult:string = home.title;
// Assert
equal(activateResult, "Home View", "Result should be Home View ");
});
here you are my typeScript settings:
any idea what is wrong with my code?
UPDATE 1 The complete message from output windows in Vs2012 is:
Test 'home.ts tests:test activate function from home viewmodel' failed Died on test #1 at file:///C:/Users/rolando/AppData/Local/Microsoft/VisualStudio/11.0/Extensions/kyo4ap1e.tvo/TestFiles/QUnit/qunit.js:412 at file:///D:/Mercatus/SourceCode/KILN/AquaVet2/SW/AquaVet.Web/App/viewmodels/_Chutzpah.7.home.tests.js:6: Can't find variable: home in D:\Mercatus\SourceCode\KILN\AquaVet2\SW\AquaVet.Web\App\viewmodels\home.tests.ts (line 6)
0 passed, 1 failed, 1 total (chutzpah).
UPDATE 2 As you see in the code i am trying load home.ts using the keyword module("home").... I am not sure if that could be the reason of my problems. A better solution could be add a internal reference to home.ts
but i don't know how I can reference to activate function !!.