Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.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
Node.js 检查应定义一个控制器_Node.js_Angularjs_Unit Testing_Testing - Fatal编程技术网

Node.js 检查应定义一个控制器

Node.js 检查应定义一个控制器,node.js,angularjs,unit-testing,testing,Node.js,Angularjs,Unit Testing,Testing,我正在检查模块PracticeCtrl中是否存在。我为此编写了以下测试 给我错误:ReferenceError:myApp未定义 describe('myApp', function() { describe('Controller: PracticeCtrl', function () { // load the controller's module beforeEach(function () { //

我正在检查模块
PracticeCtrl
中是否存在。我为此编写了以下测试

给我错误:
ReferenceError:myApp未定义

describe('myApp', function() {
    describe('Controller: PracticeCtrl', function () {            

      // load the controller's module
        beforeEach(function () {
            // Load the controller's module
            module('myApp');    
        });

        it('should have a PracticeCtrl controller', function() {
            expect(myApp.PracticeCtrl).toBeDefined();
        });    

    });
});
如何在我的模块中检查控制器是否存在?因为我是新手,所以对语法的了解较少

describe("SomeControllerTest", function () {
    var scope, ctrl;

    beforeEach(module('myApp'));

    beforeEach(inject(function($rootScope, $controller) {
        scope = $rootScope.$new();
        ctrl = $controller('SomeController', {
            $scope: scope
        });
    }));

    it("should be defined", function () {
        expect(ctrl).toBeDefined();
    });
});