在过去,我使用过webstorm、karma、jasmine和phantom来运行js测试。我现在必须在VS2015中运行测试,并选择了resharper/jasmine和phantom js。我有我的测试运行正常,它实际上看起来不错。我唯一的抱怨是,使用karma,您可以指定通配符引用,因此使用一个配置,所有引用的依赖js文件都在一个位置。现在,我必须在我创建的每个规范文件中指定引用。有没有更好的方法来做这件事?
例如,在我的规范文件的顶部,我有几个这样的东西:
///<reference path="~/Scripts/jasmine/jasmine.js"/>
///<reference path="~/Scripts/jasmine/jasmine.js"/>
///<reference path="~/Scripts/jasmine/jasmine-html.js"/>
///<reference path="~/Scripts/jasmine/boot.js"/>
///<reference path="~/Scripts/angular-core/angular.js"/>并且每个文件都有许多相同的引用被复制和粘贴。
作为附注-我还注意到在我的mvc应用程序的脚本文件夹下有一个自动生成的_references.js文件,其中似乎包含了我所有引用的文件(尽管有些路径是相对的)-我不确定是不是!
谢谢
发布于 2015-09-13 11:43:24
首先,R# 9.2会自动加载所需的jasmine文件,因此它们不需要作为引用,另外,如果您加载2.3 jasmine作为引用,它会破坏所显示页面上的css。
我发现最有效的方法是用我在所有单元测试中想要的东西创建一个testReferences.js,然后用额外的引用引用它。
testReferences.js:
/// <reference path="~/wwwroot/lib/angular/angular.js" />
/// <reference path="~/wwwroot/lib/angular-mocks/angular-mocks.js" />
/// <reference path="~/wwwroot/app/app.js" />单元测试:
/// <reference path="~/scripts/testReferences.js" />
/// <reference path="~/wwwroot/app/Production/productionQueueController.js" />https://stackoverflow.com/questions/31724513
复制相似问题