大佬教程收集整理的这篇文章主要介绍了angularjs – Karma测试:TypeError:尝试分配到只读属性,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的规范文件在下面
'use Strict'; describe('Information.controller',function () { beforeEach(angular.mock.module('asp')); var InformationController,scope; beforeEach(inject(function($controller,$rootScopE) { scope = $rootScope.$new(); InformationController = $controller('InformationController',{ $scope: scope }); })); fit('Should remove the object without info from the object',function () { InformationController.Data = [ { "ban": "03745645455","accountno": "0000DRGyt456456565","id": "2c4cc5e8-f360367" },{ "ban": "27346fgh9080","accountno": "000456456ytr655680","id": "2c4cc8ae-50bbf360367" } ]; InformationController.banList = InformationController.Data.map((value,indeX) => (value && value.ban ? {'id': index,'text': value.ban} : null)) .filter(value => value); expect(InformationController.banList.length).toBe(3); }); });
beforeEach(inject(function ($controller,$rootScopE) { scope = $rootScope.$new(); scope.page3 = {}; InformationController = $controller('InformationController',{ $scope: scope }); }));
这解决了这个问题.
以上是大佬教程为你收集整理的angularjs – Karma测试:TypeError:尝试分配到只读属性全部内容,希望文章能够帮你解决angularjs – Karma测试:TypeError:尝试分配到只读属性所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。