Javascript 我在测试角度1.5组件时遇到问题
我正在努力学习测试,我现在有很多问题 这是我最基本的部分:Javascript 我在测试角度1.5组件时遇到问题,javascript,angularjs,karma-jasmine,Javascript,Angularjs,Karma Jasmine,我正在努力学习测试,我现在有很多问题 这是我最基本的部分: (function () { "use strict"; angular.module("testList", []) .component("testList", { templateUrl: "test-list.component.html", controllerAs: "model", controller: testController }); functi
(function () {
"use strict";
angular.module("testList", [])
.component("testList", {
templateUrl: "test-list.component.html",
controllerAs: "model",
controller: testController
});
function testController() {
var model = this;
model.test = "test";
}
}());
我在测试中所做的只是确保“test”等于“test”,但我在控制台中遇到以下错误:undefined不是一个函数
"use strict";
describe("Testing Component", function () {
var $componentController;
beforeEach(module('testList'));
beforeEach(inject(function(_$componentController_) {
$componentController = _$componentController_;
}));
it("should see if test equals test", function() {
var ctrl = $componentController('testList', null, { test: "test"});
expect(ctrl.test).toEqual("test");
});
});
谁能帮帮我吗?看来你在那里没有做错什么。这是一个JSBin,其中(或多或少)有您的代码:。考试通过了 也许您没有正确加载
angularmocks.js
脚本