我正在尝试使用Grails后端的Angular应用程序,在开始使用它之前,我正在对控制器进行单元测试,只是为了查看它是否存在。不幸的是,它给了我以下错误:
points = []
for x in training_feature:
for y in x[1]:
points.append([x[0], y])
points = np.array(points)
points.shape # (80, 2)
这是我的单元测试代码:
plt.scatter(points[:, 0], points[:, 1])
这是控制器代码:
[$controller:ctrlreg] The controller with the name 'SecurityController' is not registered.
这是模块代码,为了更好的衡量标准:
import angular from 'angular';
import 'angular-mocks';
import worldManagerApp from '../../src/world-manager-app';
import security from '../../src/security/security';
const {inject, module} = angular.mock;
describe('SecurityController', () => {
let $state;
let vm;
beforeEach(module(worldManagerApp));
beforeEach(module(security));
beforeEach(inject((_$state_, $controller) => {
$state = _$state_;
spyOn($state, 'go');
vm = $controller('SecurityController', {
});
}));
it('should be registered', () => {
expect(vm).toBeDefined();
});
});
安全模块已修补到我的主app模块中,所以我也可以提供。我已经阅读了一些关于此的资源,但到目前为止,我所尝试过的任何内容都没有特别有用。
提前致谢!
答案 0 :(得分:1)
.controller(SecurityController)
.service(SignUp)
.service(AuthenticationService);
应该是
.controller('SecurityController', SecurityController)
.service('SignUp', SignUp)
.service('AuthenticationService', AuthenticationService);
您需要提供名称ov控制器/服务,然后提供其实现。