【发布时间】:2016-12-12 10:51:25
【问题描述】:
在我的 angular2 应用程序中,我有带有 var 的 js 文件“connection.conf.js”:
var appTypeConf = "example-app";
组件使用来自“connection.conf.js”的变量:
declare var appTypeConf: string;
export class Component {
public appType = appTypeConf;
}
它在我的应用程序中可以正常工作,但是当我使用 karma 测试应用程序时, 我收到一个错误:
ReferenceError: Can't find variable: appTypeConf (line 9)
如何正确声明组件spec文件中的变量?
【问题讨论】:
-
this question的可能重复
标签: unit-testing angular typescript karma-jasmine