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();
});
});