javascript - How to load a public function using QUnit and TypeScript -


i using qunit test typescript code , fine when run simple example this: http://thomasardal.com/testing-typescript-with-typescript-using-qunit-and-chutzpah/

but nightmare start when try create unit tests spa app. @ moment run testing using chutzpah on vs got 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 home viewmodel", function () {      // calling active public function home viewmodel. (home.ts)        var activateresult:string = home.title;      // assert     equal(activateresult, "home view", "result should home view ");  }); 

here typescript settings: setting typescript

any idea wrong code?

update 1 complete message output windows in vs2012 is:

test 'home.ts tests:test activate function home viewmodel' failed died on test #1 @ file:///c:/users/rolando/appdata/local/microsoft/visualstudio/11.0/extensions/kyo4ap1e.tvo/testfiles/qunit/qunit.js:412 @ 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 see in code trying load home.ts using keyword module("home").... not sure if reason of problems. better solution add internal reference home.ts

adding home.ts internal reference

but don't know how can reference activate function !!.

just adding import statement doesn't include amd module - need loader such require.js that.

a bit of googling throws https://github.com/jrburke/requirejs/wiki/test-frameworks may qunit working async modules.

and this discussion using chutzpah require, links this example.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -