Karma + ui-router失败:无法读取属性'isDefined'的定义

Karma + ui-router fails: Cannot read property 'isDefined' of undefined

本文关键字:isDefined 定义 属性 读取 ui-router 失败 Karma      更新时间:2023-09-26

我在我的Angular项目中使用ui-router。为了测试,我使用KarmaJasmine

运行Karma时,我得到以下错误:

Uncaught TypeError: Cannot read property 'isDefined' of undefined
at /Applications/MAMP/htdocs/examtesting/js/vendor/angular-ui-router.min.js:7

我怎样才能通过这个?

这是整个终端:

patrickreck@Patricks-MacBook-Pro /A/M/h/examtesting> karma start karma.conf.js 
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 35.0.1916 (Mac OS X 10.9.2)]: Connected on socket xtivwYEP-4sBQAeAlsMl with id 73870853
Chrome 35.0.1916 (Mac OS X 10.9.2) ERROR
  Uncaught TypeError: Cannot read property 'isDefined' of undefined
  at /Applications/MAMP/htdocs/examtesting/js/vendor/angular-ui-router.min.js:7

isDefined可能是angular变量的属性。所以可能angular库没有被正确加载。

你能发布Karma配置文件吗?Angular需要在Angular -ui-router.js之前加载。

Angular需要在ui-router之前加载。在我的例子中,angular的<script src..>在ui-router下面。

<script src.. (angular)> above ui-router fixes this.
<script src.. (ui-router)>`