在 stuff.js 中:
function init() {
return "works"; // just here to ensure we can access this file from the test
}
window.MyNamespace = {};
在我的测试 JS 文件中:
/// <reference path="../../../project1/Shared/sub1/Javascript/stuff.js" />
test("foo test", function () {
equal(init(), "works", "couldn't access source JS file");
ok(window, "couldn't access source JS file");
var ns = window.MyNamespace;
ok(ns, "namespace is bad");
});
我namespace is bad
在使用 Chutzpah 测试适配器运行上述测试时得到。我究竟做错了什么?qUnit/Chutzpah 不应该在尝试运行测试之前运行 stuff.js 中的代码吗?