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_Controller_Jasmine_Karma Runner - Fatal编程技术网

Angularjs 初学者的简单角度测试

Angularjs 初学者的简单角度测试,angularjs,unit-testing,controller,jasmine,karma-runner,Angularjs,Unit Testing,Controller,Jasmine,Karma Runner,我试图用angular js进行单元测试,但这并不容易 我想进行一个简单的小测试,如下所示: describe('Edition Controllers', function(){ beforeEach(module('DOPCjsControllers.controller')); it('should check a simple test', inject(function($controller) { var scope = {}; var editionCtrl = $

我试图用angular js进行单元测试,但这并不容易

我想进行一个简单的小测试,如下所示:

describe('Edition Controllers', function(){
  beforeEach(module('DOPCjsControllers.controller'));


it('should check a simple test', inject(function($controller) {
  var scope = {};
  var editionCtrl = $controller('EditionController', {$scope : scope} );
  expect(scope.test).toBe("lol");

   }));
});
我的控制器的开始:

'use strict';
/* Controllers */

var DOPCjsControllers = angular.module('DOPCjsControllers', []);

/**
*EditionController : Controlleur de gestion de la partie edition du logiciel.
*/
DOPCjsControllers.controller('EditionController', ['$scope', '$http', '$routeParams', '$filter', '$modal','$fileUploader', 'AUTH_EVENTS','NotificationFactory', 'NOTIF_STATUTS','Session','AuthService','$location',
function($scope, $http, $routeParams, $filter, $modal, $fileUploader, AUTH_EVENTS, NotificationFactory, NOTIF_STATUTS, Session, AuthService, $location){
    $scope.test = "lol";
    $scope.$on(AUTH_EVENTS.notAuthenticated, function(event){
        //alert("Connectez vous d'abord");
        console.log("notAuthenticated");

    }); etc ...
当我执行测试时,我看到: Firefox 29.0.0(Ubuntu):执行1/1(1失败)错误(0.645秒/0.011秒) 信息[观察者]:更改文件“/home/lionnel/angular seed/test/unit/controllersSpec.js”。 Firefox29.0.0(Ubuntu)版本控制器应该检查一个简单的测试失败
Miner/您的测试尝试加载名为“DOPCjsControllers.controller”的模块。你没有任何这样的模块。您正在定义的模块称为“DOPCjsControllers”:


您可能需要在测试中手动触发摘要循环。尝试放置作用域。$digest();在打电话之前。哦……您可能还需要注入$rootScope,并使用$rootScope.new()创建测试范围;
describe('Edition Controllers', function(){
beforeEach(module('DOPCjsControllers'));


    it('should check a simple test', inject(function($controller) {
      var scope = {};
      var editionCtrl = $controller('EditionController', {$scope : scope} );
      expect(scope.test).toBe("lol");

    }));
});
var DOPCjsControllers = angular.module('DOPCjsControllers', []);
        That's the name of the module ----^