我使用了yo angular 1生成器,它创建了一个登陆页面和一些测试。我无法在VS中编译代码,因为“module('fountainFooter');”未定义。
/// <reference path="../../typings/index.d.ts" />
import * as angular from 'angular';
import 'angular-mocks';
import {footer} from './footer.ts';
describe('footer component', () => {
beforeEach(() => {
angular
.module('fountainFooter', ['src/app/footer.html'])
.component('fountainFooter', footer);
module('fountainFooter');
});
it('should render \'FountainJS team\'', inject(($rootScope: ng.IRootScopeService, $compile: ng.ICompileService) => {
const element = $compile('<fountain-footer></fountain-footer>')($rootScope);
$rootScope.$digest();
const footer = element.find('a');
expect(footer.html().trim()).toEqual('FountainJS team');
}));
});
我猜这个模块是在角度模拟中定义的模块,所以我试图将模块声明为angular.mock.module。但是当我这样做时,我得到了这个错误:
PhantomJS 2.1.1 (Windows 8 0.0.0) footer component should render 'FountainJS team' FAILED
TypeError: undefined is not an object (evaluating 'angular.mock.module') (line 21)
据我所知,模块在浏览器窗口中声明。使用just模块使用gulp和systemjs。当我使用angular-mock.module时,VS和typescript很高兴,但是诅咒没什么用。
答案 0 :(得分:0)
这是一种方法。
"K14:"
也取自yo angular#1生成器,但使用选项脚本注入生成。