我正在尝试使用通过Teaspoon运行的Jasmine在Angular中创建一些单元测试。测试正在运行,但是我有一个简单的测试只是为了测试失败的控制器的存在。我有以下测试设置。
//= require spec_helper
require("angular");
require("angular-mocks");
var app = require("./app");
describe("My App",function() {
describe("App Controllers",function() {
beforeEach(module("app"))
it("Should have created an application controller",inject(function($rootScope,$controller){
var scope = $rootScope.$new();
ctrl = $controller("ApplicationCtrl",{ $scope: scope });
}));
})
})
请求语句由browserify处理,它处理我的依赖项,但我也可以挂钩到我用于规范帮助程序的sprockets。
在我需要的应用程序内部
require("angular");
var controllers = require("./controllers");
var app = angular.module("app",[
"app.controllers"
]);
exports.app = app;
当我运行此测试时,我得到以下错误
Failure/Error: TypeError: '[object Object]' is not a function (evaluating 'module("aialerts")')
我花了很长时间试图解决这个问题,但我不知道发生了什么。任何帮助赞赏。
我有同样的问题。改变这一行:
beforeEach(module("app"))
至:
beforeEach(angular.mock.module("app"))