每当我尝试运行单元测试(使用buster编写并执行用户buster test)并包含jQuery (因为我的库依赖于它)时。我得到以下错误:
./test/deps/jquery-1.7.2.min.js: window is not defined
下面是我的配置文件: var buster.js = module.exports;
config["GitJs Tests"] = {
rootPath: "../",
environment: "node",
sources: [
"src/Gitjs.js"
],
deps: [
"test/deps/*.js" // Jquery is in here
],
tests: [
"test/test_constructor.js"
]
};为什么我会得到这个错误,我如何修复它?
发布于 2012-09-07 03:55:04
我做了一些挖掘,发现了这个错误,因为在Node中运行时,没有窗口。jQuery需要window对象才能正常工作。
简而言之:你不能在NodeJs中使用jQuery (至少不能使用它的原生格式:D)。如果你想使用jQuery和busterJs,你需要在浏览器模式下运行它。
https://stackoverflow.com/questions/11286839
复制相似问题