Tag: 业力运行

Angular 2unit testing – 获取错误无法加载“ng:///DynamicTestModule/module.ngfactory.js”

我有angular 2 webpack应用程序,所有webpack,根据angular.io webpack指南创build的业力configuration。 我不使用aot。 我正在写茉莉花unit testing规范来testing我的组件。 首先,我尝试没有asynchronous块,在这种情况下,unit testing只是得到执行,直到fixture.detectChanges()调用,之后的代码不会得到执行。 好像fixture.detectChanges调用无限地被阻塞。 我试图通过在asynchronous块中包含代码。 然后我得到以下错误。 错误:无法在'XMLHttpRequest'上执行'发送':无法加载'ng:/// DynamicTestModule /module.ngfactory.js' 代码没有asynchronous beforeeach(()=> { TestBed.configureTestingModule({ imports:[], declaration :[Mycomp], providers:[{ provide:MyService, useclass:MyMockService}] }); fixture=TestBed.createComponent(Mycomp); console.log(' before detect changes'): fixture.detectChanges(): console.log('after detect changes');// this is not getting logged .. karma shows 0 of 1 executed successfully }); 与asynchronous beforeeach(async(()=> { TestBed.configureTestingModule({ imports:[], declaration […]

在Angular应用程序的Karmatesting文件中包含依赖项?

我正在尝试开始使用Karmatesting,将它们添加到现有的Angular应用程序中。 这是我的主要应用程序定义文件: angular .module('myApp', [ 'ngRoute', 'moduleAdherence' ]); 这是我的控制器文件: angular .module('moduleAdherence', []) .controller('AdherenceCtrl', ['$scope', function ($scope) { $scope.awesomeThings = [1,2,3,4]; }]); 这是我第一次戳文件: describe('Controller: AdherenceCtrl', function () { beforeEach(module('myApp')); var MainCtrl, scope; beforeEach(inject(function ($controller, $rootScope) { scope = $rootScope.$new(); MainCtrl = $controller('AdherenceCtrl', { $scope: scope }); })); it('should attach a list of awesomeThings to the scope', […]