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 使用莫卡、柴、辛诺JS进行测试时,未定义角度误差_Angularjs_Unit Testing_Coffeescript_Mocha.js - Fatal编程技术网

Angularjs 使用莫卡、柴、辛诺JS进行测试时,未定义角度误差

Angularjs 使用莫卡、柴、辛诺JS进行测试时,未定义角度误差,angularjs,unit-testing,coffeescript,mocha.js,Angularjs,Unit Testing,Coffeescript,Mocha.js,我的问题就在这里,我试图在角度范围内测试控制器。这是控制台在运行命令mocha--compilers coffee:coffee script/register**/*.spec.coffee以运行项目中的所有测试文件时向我抛出的错误 angular.module('weaver.ui.app'); ^ ReferenceError: angular is not defined 我最近添加了angular mock库,确保angular不是未解析的变量,但这并不能解决问题 我的测试文

我的问题就在这里,我试图在角度范围内测试控制器。这是控制台在运行命令
mocha--compilers coffee:coffee script/register**/*.spec.coffee
以运行项目中的所有测试文件时向我抛出的错误

  angular.module('weaver.ui.app');
  ^
ReferenceError: angular is not defined
我最近添加了
angular mock
库,确保angular不是未解析的变量,但这并不能解决问题

我的测试文件的开头如下所示(代码是用CoffeeScript编写的)

如果我取消注释require angular,则错误将变为以下内容,因此我假设这不是正确的方法

\npm\node_modules\angular\angular.js:29016
})(window, document);
   ^

ReferenceError: window is not defined
如果我完全删除angular.module'weaver.ui.app'行,我会得到一个类似的错误,但这是关于控制器的错误

  angular.module('weaver.ui.app').controller('AppDesignSidebarNewcontentCtrl', function($rootScope, $scope) {});
  ^

ReferenceError: angular is not defined
我希望这里有人能帮我解决这个问题,这个问题困扰了我很长一段时间

请不要以控制员的名字来评判我;)

  angular.module('weaver.ui.app').controller('AppDesignSidebarNewcontentCtrl', function($rootScope, $scope) {});
  ^

ReferenceError: angular is not defined