【发布时间】:2015-04-17 14:02:01
【问题描述】:
我在一个解决方案下有两个项目,一个是我的主要 Web 项目,例如 MyProject,另一个用于测试目的,例如 MyProject.Tests。
Solution
MyProject
MyProject.Tests
我想让我的 JavaScript 无头测试运行到第二个。
在第一个项目中,所有的 javascript 文件都在 Scripts 目录下,如下所示:
Scripts/
Common.js
Libs/
jquery/
jquery.js
requirejs/
require.js
在测试项目中,我的 chutzpah.json 文件位于根目录下。
MyProject.Tests
chutzpah.json
Tests/
Specs/
spec.js
文件有这样的配置:
{
"Framework": "jasmine",
"TestHarnessReferenceMode": "AMD",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"Tests": [ { "Path": "Tests/Specs" } ],
"AMDBasePath": "../MyProject/Scripts",
"CodeCoverageExcludes": ["*Common.js"],
"References": [
{ "Path": "../MyProject/Scripts/Libs/requirejs/require.js" },
{ "Path": "../MyProject/Scripts/Common.js" }
]
}
但是当我尝试运行规范文件时,我得到一个错误。
规格文件:
define(["jquery"], function ($) {
//code here. Doesn't matter, the error is because of the jquery module
});
错误是这样的:
Error: Error opening C:/Users/g.dyrrahitis/Documents/Visual Studio 2013/Projects/MySolution/MyProject.Tests/Scripts/Libs/jquery/jquery.js: The system cannot find the path specified.
问题是 chutzpah 试图在测试项目而不是它所在的主项目中找到我的 jquery 模块。
为什么我会出现这种行为,请问我该如何解决?到目前为止,我已经尝试了几个小时来解决这个问题。
注意
*名称MySolution, MyProject, MyProject.Tests是为了清楚起见,而不是使用真实姓名。
【问题讨论】:
标签: javascript visual-studio-2013 requirejs amd chutzpah