Javascript jQuery出现Buster.js依赖项错误:未定义窗口
每当我尝试运行我的单元测试(使用buster编写并执行userJavascript jQuery出现Buster.js依赖项错误:未定义窗口,javascript,jquery,unit-testing,buster.js,Javascript,Jquery,Unit Testing,Buster.js,每当我尝试运行我的单元测试(使用buster编写并执行userbuster test)并包含jQuery时(因为我的库依赖于它)。我得到以下错误: /test/deps/jquery-1.7.2.min.js:未定义窗口 这是我的buster.js配置文件: var config=module.exports config["GitJs Tests"] = { rootPath: "../", environment: "node", sources: [
buster test
)并包含jQuery时(因为我的库依赖于它)。我得到以下错误:
/test/deps/jquery-1.7.2.min.js:未定义窗口
这是我的buster.js配置文件:
var config=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"
]
};
为什么会出现此错误以及如何修复它?进行了一些挖掘,发现您会出现此错误,因为在节点中运行时,没有窗口。jQuery需要
窗口
对象才能正常工作
简而言之:您不能在NodeJs中使用jQuery(至少不能在其本机格式中使用:D)。如果你想使用jQuery和busterJs,你需要在“浏览器”模式下运行它