Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在angularjs单元测试中将引用提取到一个外部文件中_Angularjs_Unit Testing_Typescript_Jasmine - Fatal编程技术网

如何在angularjs单元测试中将引用提取到一个外部文件中

如何在angularjs单元测试中将引用提取到一个外部文件中,angularjs,unit-testing,typescript,jasmine,Angularjs,Unit Testing,Typescript,Jasmine,我正在使用Jasmine为我的AngularJS项目编写单元测试,但它似乎很枯燥,因为在每个规范文件中,我都必须添加一些如下所示的引用 /// <reference path="../../../bower_components/jasmine/lib/jasmine-core/jasmine.js" /> /// <reference path="../../../bower_components/jasmine/lib/jasmine-core/jasmine-html.j

我正在使用Jasmine为我的AngularJS项目编写单元测试,但它似乎很枯燥,因为在每个规范文件中,我都必须添加一些如下所示的引用

/// <reference path="../../../bower_components/jasmine/lib/jasmine-core/jasmine.js" />
/// <reference path="../../../bower_components/jasmine/lib/jasmine-core/jasmine-html.js" />
/// <reference path="../../../bower_components/jasmine/lib/jasmine-core/boot.js" />
/// <reference path="../../../bower_components/jquery/dist/jquery.min.js" />
/// <reference path="../../../bower_components/jquery/dist/jquery.js" />
/// <reference path="../../../bower_components/angular/angular.js" />
/// <reference path="../../../vendors/js/jBox.js" />
/// <reference path="../../../bower_components/angular-mocks/angular-mocks.js" />
//
/// 
/// 
/// 
/// 
/// 
/// 
/// 
等等

有没有办法将引用提取到一个外部文件中,然后我只在每个测试规范文件中添加该文件。

您最好使用它来管理您的第三方类型库。其工作原理如下(复制自):

然后,一旦完成此操作,在每个文件中,或者在每个测试文件中放置对
typings/index.d.ts
/
引用。或者(这更好)在tsconfig文件中输入
typings/index.d.ts
,如下所示:

{
  "files": [
    "typings/index.d.ts"
  ]
}

您使用的是什么版本的typescript?您可以创建一个供所有脚本使用的打字文件,但此功能仅在较新版本的typescript中可用。您好,Andrew,我使用的是typescript 1.7版。你能帮我解释一下你建议的方法吗。谢谢
{
  "files": [
    "typings/index.d.ts"
  ]
}